Hi everybody
Been away for a while but lucky enough to just get a new job, hoping someone can help me out a bit on the last part of a VBA project. Using Office 2010
I have been working on some code to save selected sheets in an excel workbook as a named PDF document. The name is a cell value (D5) on a sheet (PSW) which is the only sheet in the workbook I don’t need as pdf. The file path as you see is hardcoded.
The Error is this line ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:=Path & filename
The code seems to be running OK but can’t be sure as the file is not saving in the correct location (or may not be saving at all as I can’t find it)
Thanks in advance, much appreciated
Gary
Been away for a while but lucky enough to just get a new job, hoping someone can help me out a bit on the last part of a VBA project. Using Office 2010
I have been working on some code to save selected sheets in an excel workbook as a named PDF document. The name is a cell value (D5) on a sheet (PSW) which is the only sheet in the workbook I don’t need as pdf. The file path as you see is hardcoded.
The Error is this line ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:=Path & filename
The code seems to be running OK but can’t be sure as the file is not saving in the correct location (or may not be saving at all as I can’t find it)
Thanks in advance, much appreciated
Gary
Code:
Sub PDF()
Dim Ws As Worksheet
Dim CurrentSheet As Worksheet
Dim wb As Workbook
Dim filename As String
Dim x As Long
Application.ScreenUpdating = False
ChDrive "W:\"
filename = Worksheets("PSW").Range("D5").Text & ".pdf"
Path = "W:\QA\QA Main\Inspection Reports\_To Be Approved"
For x = 2 To ThisWorkbook.Sheets.Count
If Sheets(x).name <> "PSW" Then Sheets(x).Select Replace:=False
Next x
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:=Path & filename
Sheets("PSW").Select
Application.ScreenUpdating = True
End Sub
Last edited: