purpleozzie
Board Regular
- Joined
- Jun 8, 2015
- Messages
- 64
Hi guys,
I use this piece of VBA Code to save a file as a PDF on to a users desktop.. I would like to change it so it changes the filename depnding on a cell reference and todays date...
Sub create()
'
' Macro1 Macro
'
'
Sheets("QUOTE SHEET").Select
Sheets("QUOTE SHEET").Copy
Dim oSHELL As Object, sDesktopPath As String
Set oSHELL = CreateObject("WScript.Shell")
sDesktopPath = oSHELL.SpecialFolders("Desktop")
ChDir sDesktopPath
ActiveWorkbook.SaveAs Filename:= _
sDesktopPath & "\Customercopy.xlsx", FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
sDesktopPath & "\Customercopy.pdf", Quality:=xlQualityStandard _
, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True
ActiveWindow.Close
End Sub
the cell reference is from a different worksheet called 'June 2015' and I want the date format in dd-mm-yy..
Next month the worksheet will be renamed July 2015 and I also want it to be able to update to still work..
Cheers,
I use this piece of VBA Code to save a file as a PDF on to a users desktop.. I would like to change it so it changes the filename depnding on a cell reference and todays date...
Sub create()
'
' Macro1 Macro
'
'
Sheets("QUOTE SHEET").Select
Sheets("QUOTE SHEET").Copy
Dim oSHELL As Object, sDesktopPath As String
Set oSHELL = CreateObject("WScript.Shell")
sDesktopPath = oSHELL.SpecialFolders("Desktop")
ChDir sDesktopPath
ActiveWorkbook.SaveAs Filename:= _
sDesktopPath & "\Customercopy.xlsx", FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
sDesktopPath & "\Customercopy.pdf", Quality:=xlQualityStandard _
, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True
ActiveWindow.Close
End Sub
the cell reference is from a different worksheet called 'June 2015' and I want the date format in dd-mm-yy..
Next month the worksheet will be renamed July 2015 and I also want it to be able to update to still work..
Cheers,