Hi All,
I wrote a macro that will loop through all open workbooks and save each and print each to pdf. It saves fine and it prints to PDF fine but it makes me enter the file name of the pdf manually. I would like it to use the filename for each workbook as the filename for each pdf file printed. Any thoughts would be welcomed.
I wrote a macro that will loop through all open workbooks and save each and print each to pdf. It saves fine and it prints to PDF fine but it makes me enter the file name of the pdf manually. I would like it to use the filename for each workbook as the filename for each pdf file printed. Any thoughts would be welcomed.
Code:
[FONT=Verdana]Sub SB()[/FONT]
[FONT=Verdana]Dim singlebook As Workbook
Dim filename As String
Dim xlWrkSht As Worksheet
Dim fil As Scripting.File[/FONT]
[FONT=Verdana]
For Each singlebook In Workbooks
singlebook.Activate
'filename = ActiveWorkbook.Name[/FONT]
[FONT=Verdana]singlebook.SaveAs
With ActiveWorkbook[/FONT]
[FONT=Verdana]
ActiveWorkbook.PrintOut ActivePrinter:="microsoft print to pdf", prtofilename:=True[/FONT]
[FONT=Verdana]
End With
Next singlebook[/FONT]
[FONT=Verdana]
End Sub[/FONT]