• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Expert PDF Help

Spacey88

New Member
Remember to include links to other site(s) you have posted this question on
Hey Everyone

I'm very new to VBA used excel a fair bit and can record Marcos ect... the easy stuff but I need to create a button the selects a range and then exports it to a PDF. Obviously you can do this just recording a macro but every time I do this it exports the range to a particular path and filename.... What I want the user to be able to do is select there own path and filename essentially so it stays at the export save screen. I've tried so many ways and just get errors don't really know what I'm doing lol. Even asked ChatGTP! I've seen alot of videos using the SaveAs Function that can even be customised, this would be great but as far as i can tell this doesn't work for what I am looking for! any help would be great.

TIA
 
Last edited by a moderator:
Hello, see in VBA help the Application.GetSaveAsFilename & Range.ExportAsFixedFormat methods.​
A thread sample :​
 
I don't think this is the same problem as me I don't want it to save to a particular location.

thanks for your reply though
 
As my post #2 answers to your initial post, you did not ever read the VBA help !​
Anyway, you can start activating the Macro Recorder and operating manually …​
 
Code:
Sub SaveSelectionAsPDF()

Dim saveLocation As String
saveLocation = "C:\Users\logit\OneDrive\Desktop\myPDFFile.pdf"

'Save selection as PDF
Selection.ExportAsFixedFormat Type:=xlTypePDF, _
    Filename:=saveLocation

End Sub
 
Back
Top