I am working on adjusting an Excel file and am trying to get the save to .pdf to work and the macro runs with no errors but the save to .pdf is not working. Below is the VBA script
VBA Code:
Sub Printpdf()
'
' Printpdf Macro
' Saves each sheet as a pdf
'
' Keyboard Shortcut: Ctrl+w
'
'Set X = 6 for start of loop
x = 6
Do Until x = 250
'Check for blank row in data sheet and stop looping
Sheets("data sheet").Select
Cells(x, 1).Select
If Cells(x, 1) = 0 Then
x = 250
Else
Sheets("scorecard").Select
'Copy Supplier name from "data sheet" row "x" to "scorecard" sheet
Sheets("data sheet").Select
Cells(x, 1).Select
Selection.Copy
Sheets("scorecard").Select
Range("E2").Select
ActiveSheet.Paste
' Set variable s equal to supplier name in "scorecard" sheet
s = Range("M5").Value
' Save the sheet as a pdf with the name "s"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
s, Quality:=xlQualityStandard, IncludeDocProperties _
:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
saveLocation = "C:\Users\kpost\Downloads"
'Increment value of x for loop
x = x + 1
End If
Loop
End Sub
Last edited by a moderator: