Reputation: 169
Im trying to save a selection to pdf, everything works fine except that I cant save the file with and specific name, I want the name to be report Sub and the date and time ... it works fine except when I try to put today date and time... this is my code
Sub guardar_pdf()
'
' Macro7 Macro
'
'
Range("A1:Q4").Select
With ActiveSheet.PageSetup
.Orientation = xlLandscape
.Zoom = 60
.PrintGridlines = True
End With
Dim fe As String
fe = now
With Selection
.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\Diego\Dropbox\informes\informe"&fe, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
End With
End Sub
Upvotes: 0
Views: 1700
Reputation: 1931
There's a couple ways you could fix this.
fe = Format(Now, "yyyymmdd_hhmmss")
Or ignore that and just do this
"C:\Users\Diego\Dropbox\informes\informe" & Format(Now, "yyyymmdd_hhmmss")
Upvotes: 2