VB help please - Save as pdf in specific folder

JV0710

Active Member
Joined
Oct 26, 2006
Messages
440
Office Version
  1. 365
  2. 2016
  3. 2013
Platform
  1. Windows
Good Day All

Please can you help me with a VB Script

I have an excel file that I am refreshing on a weekly basis. The worksheet is protected. I would like a macro to save the Active worksheet as a pdf using the text in Cell A1 as the name of the file. The file must be saved on the users desktop in a folder named: “ Sup info “.
If the folder does not exist on the user’s desktop then create it and name it “ Sup Info ”.
If a file with the same name exists in the folder, then replace it

Thanks in advance for your help
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try this:

VBA Code:
Sub savePDF()
  Dim sPath As String, sName As String
  
  sPath = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\Sup info"
  If Dir(sPath, vbDirectory) = "" Then MkDir sPath
  sName = sPath & "\" & Range("A1").Text & ".pdf"
  
  ActiveSheet.ExportAsFixedFormat xlTypePDF, sName, xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End Sub
 
Upvote 0
Solution
Thank you Sir, Appreciate it . . . That has worked perfectly for me
 
Upvote 0

Forum statistics

Threads
1,224,901
Messages
6,181,638
Members
453,059
Latest member
jkevin

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