picklefactory
Well-known Member
- Joined
- Jan 28, 2005
- Messages
- 506
- Office Version
- 365
- Platform
- Windows
Hi folks
Hope this is a very quick easy one.
I have a bit of code that saves a single work sheet as a pdf using the print header as the file name (Which is just today's date). I now need to be doing the same thing but saving as .xlsx rather than pdf, is that a simple change?
Thanks
Hope this is a very quick easy one.
I have a bit of code that saves a single work sheet as a pdf using the print header as the file name (Which is just today's date). I now need to be doing the same thing but saving as .xlsx rather than pdf, is that a simple change?
Thanks
VBA Code:
Sub AddHeader_CurrentSheetOnly()
'Add P1 from active sheet to active sheet's header
Sheets("PAYROLL TO SEND").Select
With ActiveSheet.PageSetup
.LeftHeader = Format(Range("P1"), "dd/mm/yyyy")
End With
' Save PDF copy of 'Payroll to Send' sheet
Dim Path As String
Dim SaveAsStr As String
Path = Worksheets("PAYROLL TO SEND").Range("P1").Text
SaveAsStr = "M:\COMPANY SHARED\wages 2\TIMESHEETS HISTORY\" & Path
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=SaveAsStr & ".pdf", _
OpenAfterPublish:=True
End Sub