Hi, Several years ago, this forum helped me create a VB macro to print multiple worksheets to separate PDF's. The code is below. Now, I need to change the code so that it prints to either a separate CSV or XLSX file. Either is fine. I've played around with it but I'm not having any luck. I'm hoping someone can help.
Sub SaveWorksheetsAsPDFs()
Dim sFile As String
Dim sPath As String
Dim wks As Worksheet
Thank you
Brenda
Sub SaveWorksheetsAsPDFs()
Dim sFile As String
Dim sPath As String
Dim wks As Worksheet
With ActiveWorkbook
sPath = .Path& "\2016 10 Invoice Copies"
IfLen(Dir(sPath)) = 0 Then MkDir sPath 'folder doesn't already exist
For Each wksIn .Worksheets
IfLen(Dir(sPath)) = 0 Then MkDir sPath 'folder doesn't already exist
For Each wksIn .Worksheets
If Not wks.Name Like "*DoNotPrint*" Then 'don't print datasheets
sFile = Format(WorksheetFunction.EoMonth(Now(), -1), "MM YYYY ")& wks.Name & ".pdf"
wks.ExportAsFixedFormat Type:=xlTypePDF, _
wks.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=sPath & sFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End If
Next wks
End With
End SubThank you
Brenda