Steven Behr
Member
Members
Power Query
Power Query
Forum Posts: 85
Member Since:
January 30, 2020
January 30, 2020
Offline
Hi,
I have completed a VBA PDF report that has a save as dialog box but I need to reference a cell from excel that automatically inputs that information into the saveAS dialog box.
the PDF VBA is as follows
Sub PrintPDFIncidentReport2()
'turn off screenupdating
Application.ScreenUpdating = False
'open dialog and set file type
Opendialog = Application.GetSaveAsFilename("", filefilter:="PDF Files (*.pdf), *.pdf", _
Title:="Personal Incident Report")
'if no value is added for file name
If Opendialog = False Then
MsgBox "Cancelled"
Exit Sub
End If
'set the named range for the PDF
Set Myrange = Sheet5.Range("B1:I32")
Sheet5.PageSetup.PrintArea = "B$1:$I$32"
'create the PDF
On Error Resume Next
'ActiveSheet.PrintOut
'Worksheets("Report3").PrintOut from:=1, To:=1
Myrange.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=Opendialog, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
On Error GoTo 0
'clear the page breaks
ActiveSheet.DisplayPageBreaks = False
Application.ScreenUpdating = False
RefID_Indicator
Ref
End Sub
'turn off screenupdating
Application.ScreenUpdating = False
'open dialog and set file type
Opendialog = Application.GetSaveAsFilename("", filefilter:="PDF Files (*.pdf), *.pdf", _
Title:="Personal Incident Report")
'if no value is added for file name
If Opendialog = False Then
MsgBox "Cancelled"
Exit Sub
End If
'set the named range for the PDF
Set Myrange = Sheet5.Range("B1:I32")
Sheet5.PageSetup.PrintArea = "B$1:$I$32"
'create the PDF
On Error Resume Next
'ActiveSheet.PrintOut
'Worksheets("Report3").PrintOut from:=1, To:=1
Myrange.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=Opendialog, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
On Error GoTo 0
'clear the page breaks
ActiveSheet.DisplayPageBreaks = False
Application.ScreenUpdating = False
RefID_Indicator
Ref
End Sub
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Riny van Eekelen, Ali Asghar
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
1 Guest(s)
Top Posters:
Catalin Bombea: 1917
SunnyKow: 1432
Anders Sehlstedt: 900
Purfleet: 414
Frans Visser: 346
David_Ng: 306
Hans Hallebeek: 289
lea cohen: 246
Jessica Stewart: 219
A.Maurizio: 216
Newest Members:
chutima thongnan
David Ball
Ali Asghar
Carmen Arico
Raymond Costelloe
Jeanette Noriega
Michael Padilla
Edward Atalla
John Woodley
Alexandra Tataru
Forum Stats:
Groups: 3
Forums: 24
Topics: 6876
Posts: 30138
Member Stats:
Guest Posters: 49
Members: 33687
Moderators: 2
Admins: 3
Administrators: Mynda Treacy, Philip Treacy, Jessica
Moderators: Velouria, Riny van Eekelen
© Simple:Press —