willow1985
Well-known Member
- Joined
- Jul 24, 2019
- Messages
- 886
- Office Version
- 365
- Platform
- Windows
This code works just fine in another spreadsheet I use. All I have to do is set what I want printed (set print area) and then run this code however with a new spreadsheet I have I am getting error 1004 and I am not sure why.
Here is the code, any idea what I could be missing?
The cell references for file name and file locations in Z1 and Z2 are formulas. Is there something I have to do to the code to make it understand/read the formula result value for the directory in Z1?
Here is the code, any idea what I could be missing?
The cell references for file name and file locations in Z1 and Z2 are formulas. Is there something I have to do to the code to make it understand/read the formula result value for the directory in Z1?
VBA Code:
Sub SavePDF()
'
' SavePDF Macro
'
Dim Path As String
Dim filename As String
Path = Sheets("Defects by Workstation Table").Range("Z1")
filename = Sheets("Defects by Workstation Table").Range("Z2")
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:=Path & filename & ".pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=True
'
End Sub