Saving an open PDF as something from Excel with VBA

jacksongf

New Member
Joined
Mar 23, 2017
Messages
21
I'm creating a report where I open a handful of spreadsheets containing data, and then run the macro from the "master sheet", which then pulls data from these sheets and pastes it in. This is fine, it works and there's no problems. BUT, one of the files is a PDF and the only thing I need to do with it is to save as a certain name, we'll call it "PDF 1", and also save it to a specific location. (The location is sharepoint, and I have the address for it, so that shouldn't be an issue).

Any code to refer to an open PDF file and then save as something would be very helpful, I can't find anything anywhere online about this!

Thanks,
Jackson
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
I don't know a lot about VBA but this is my attempt to save an open file to a PDF

you would have to add this to your current VBA and create a button.

Not sure this is what you are looking for because this is for the open excel file and not a PDF file.

Code:
Sub PDFMacro1()
'
' save open file as a PDF
'
    ChDir "C:\Users\Desktop"  ' your path
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        "C:\Users\Desktop\newname.pdf", Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
        True
End Sub
 
Upvote 0
I don't know a lot about VBA but this is my attempt to save an open file to a PDF

you would have to add this to your current VBA and create a button.

Not sure this is what you are looking for because this is for the open excel file and not a PDF file.

Code:
Sub PDFMacro1()
'
' save open file as a PDF
'
    ChDir "C:\Users\Desktop"  ' your path
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        "C:\Users\Desktop\newname.pdf", Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
        True
End Sub

Yes, it looks like he's trying to save an already-open PDF instead of trying to save a worksheet as PDF. I really don't think (though, I also don't know) this is even possible.
 
Upvote 0
Yes, I'm not completely sure if it's possible either. I'll keep trying. Thanks for the help!

If anyone does does know how to do this and stumbles across this thread, please share your ways!

Thanks,
Jackson
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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