Converting to PDF and Saving to SharePoint

davidanaya11579

New Member
Joined
Dec 26, 2017
Messages
11
Greetings,

I am attempting to write a macro to save the current sheet (sheet1) as a PDF to a SharePoint site, using the value of C3 as the file name. The below is what I have.
Private Sub CommandButton4_Click()
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"http://worknet/sites/clevelandgf/insidesales/Transactional Quotes/Forms/AllItems.aspx" & Range("C3").Value & ".pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:= _
True

End Sub

It seems to run correctly, I can see the SharePoint site open in the background, and the completed PDF opens, but the file never actually saves to the SP site. Any ideas?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
The link you are using is not a document library folder location (and it is normally https with sharepoint), your link goes to the page allitems.aspx.

I created this quick bit of code for my test sharepoint site and it uploaded it, have a look and amend it to match yours and let us know if you have issues.

It puts it in my test site under shared documents (the default for my sharepoint docs) and into a folder called General.


Code:
Sub Macro1()
'
' Macro1 Macro
'
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
        "https://COMPANY.sharepoint.com/sites/TEAMNAME/Shared%20Documents/General/" & Range("C3").Value & ".pdf" _
        , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
        :=False, OpenAfterPublish:=False
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,698
Members
448,979
Latest member
DET4492

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