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
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
.

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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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
Back
Top