Inserting the "DateString" into file name
HI, I have been able to add my Date string into a header by doing the following commands...
'Date Set WksRange = Wks.Cells("C60") 'Worksheet Column = C, Row = 10 Debug.Print WksRange.Value dateFromWks = WksRange.Value DateString2 = Format(dateFromWks, "dd/MM/yyyy")
Set
Text= Plot.Shapes.AddText(x:=6.1, y:=0.7, Text:= "" +Str(DateString2) + " Serpentine River")
But
How do I insert the DateString into my export file name, with a different date format of YYYMMDD ?
Plot.Export2 (FileName:="T:\S&P\W&LU\WS\ESTUARY Team\SURFER\Peel Harvey\PH_wq_#DATESTRING#.png", Options:="ColorDepth:=32,BackgroundTransparency=0", FilterId:="PNG")
My final export file name needs to be: PH-wq_YYYYMMDD.png
Thanks
-
Hello Sayce,
You will need to define a string from the worksheet column containing your date/time value, and then you can use the Format command to format it in the desired yyyyMMdd format. Katie sent you instructions for how to do this back in December. I've copied her code here, replacing the date/time format she defined with your yyyyMMdd format.
Dim Wks As Object
Dim dateFromWks As Date
Set Wks = SurferApp.Documents.Open("C:\Temp\demogrid_dates.xls")
Dim WksRange As Object
Set WksRange = Wks.Cells("C2")
dateFromWks = WksRange.Value
DateString = Format(dateFromWks, "yyyyMMdd")
Wks.Close
Dim Plot As Object
Set Plot = SurferApp.Documents.Add
Set Text1 = Plot.Shapes.AddText(x:=2.00, y:=11.15, Text:="Collie River - Physical-chemical Profile "+ Str(DateString))Thanks,
Leslie
Please sign in to leave a comment.
Comments
1 comment