ColdGeorge
Active Member
- Joined
- Aug 21, 2012
- Messages
- 407
- Office Version
- 2016
- Platform
- Windows
Hi all
Cancel button of second InputBox is not working properly, please take a look at this code.
Thanks in advance.
ColdGeorge
Cancel button of second InputBox is not working properly, please take a look at this code.
Thanks in advance.
ColdGeorge
VBA Code:
Dim rng As Range
Dim newpdfname As String
Dim pdfpath As String
'Enter range
On Error Resume Next
Set rng = Application.InputBox(Prompt:="Please Select", Title:="Get Range", Type:=8)
On Error GoTo 0
If rng Is Nothing Then Exit Sub
'Enter name for file
On Error Resume Next
newpdfname = Application.InputBox(Prompt:="Now, Enter name for file", Title:="Get name", Type:=2)
On Error GoTo 0
If newpdfname = "" Then Exit Sub
pdfpath = ThisWorkbook.Path & "\" & newpdfname
rng.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=pdfpath, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True