VBA to save file as PDf eliminate the save as pop-up

lbradbury

New Member
Joined
May 14, 2020
Messages
46
Office Version
  1. 365
Platform
  1. Windows
Hi, I have a code that runs fine, I just would like to eliminate the pop-up save as pop-up. The code is below.
VBA Code:
Private Sub SaveAs()
'This macro opens the SaveAs option with the defult file path "you have to set this file path below" coverts the whole sheet into .pdf file format
'And opens the .pdf to view <-- you can disable the view after covert option with lower code: OpenAfterPublish:=False

    pdfName = ActiveSheet.Range("E21")
    ChDir "I:\MSI-Projects\Global Shop Implementation\Time\" 'This is where youo set a defult file path.
    fileSaveName = Application.GetSaveAsFilename(pdfName, _
    fileFilter:="PDF Files (*.pdf), *.pdf")
    If fileSaveName <> False Then
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        fileSaveName _
        , Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas _
        :=False, OpenAfterPublish:=True
     
     
    End If
    MsgBox "File Saved to" & " " & fileSaveName
End Sub
 

Some videos you may like

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Logit

Well-known Member
Joined
Aug 31, 2016
Messages
3,951
.

Try this :

VBA Code:
Option Explicit

Sub SavePDF()

    With ActiveSheet
               
        .ExportAsFixedFormat Type:=xlTypePDF, Filename:="I:\MSI-Projects\Global Shop Implementation\Time\" & Range("E21").Value & ".pdf", _
        Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
       
      End With
   
End Sub
 

Boorin

New Member
Joined
Oct 19, 2016
Messages
2
Replying to your question from "Macro to save worksheet as PDF." thread. I've come up with a completely different code and it worked great much much easier and simplier, no pop up and the location is exactly where I wanted to save each time. Please try below code. Hope this helps!

"
Sub Macro1()
'
' Macro1 Macro
'
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
""C:\your folder destination here"" & Worksheets(""tab name to save as PDF"").Range(""the cell you want as part of your name"") & "" - "" & ActiveSheet.Name, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False

End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,127,098
Messages
5,622,677
Members
415,921
Latest member
ExcelNoob28

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top