Excel Macro exporting to sheet as pdf to sharepoint

excel_learnerz

Board Regular
Joined
Dec 12, 2018
Messages
73
I am new to VBA and have to complete a task for my manager about saving sheet as a pdf into sharepoint (if firstly can be done) which creates a folder at the location with the same name as the saved PDF and saves the pdf there.Now where it gets harder for me is at the location in sharepoint there are 3 folders, for USD, EUR and GBP and depending on a field in the excel (which will denote one of the 3 currencies) it will have to be saved at that location(Sharepoint URL or mapped to network drive)\Quote\USD\new folder created with file name matching pdf\pdf file(Sharepoint URL or mapped to network drive)\Quote\EUR\new folder created with file name matching pdf\pdf file(Sharepoint URL or mapped to network drive)\Quote\GBP\new folder created with file name matching pdf\pdf fileIs it the sharepoint URL will work or is it only when mapped to the network drive (which I have with a filepath with my username which im guessing would stop working from anyone else but me)I am using the below which saves to sharepoint but with me as User_1 I cant see how anyone else will be able to?
<code style="background-color: rgb(239, 240, 241); border-bottom-color: rgb(57, 51, 24); border-bottom-style: none; border-bottom-width: 0px; border-image-outset: 0; border-image-repeat: stretch; border-image-slice: 100%; border-image-source: none; border-image-width: 1; border-left-color: rgb(57, 51, 24); border-left-style: none; border-left-width: 0px; border-right-color: rgb(57, 51, 24); border-right-style: none; border-right-width: 0px; border-top-color: rgb(57, 51, 24); border-top-style: none; border-top-width: 0px; box-sizing: border-box; font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,sans-serif; font-size: 13px; font-size-adjust: none; font-stretch: 100%; font-style: normal; font-variant: normal; font-weight: 400; line-height: 16.9px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline; white-space: pre;">Sub test()

ChDir
"C:\Users\user_1\company\Sales Team - Documents\Quotes"
With Sheets("Quote")

.ExportAsFixedFormat _
Type
:=xlTypePDF, _
Filename
:="C:\Users\user_1\company\Sales Team - Documents\Quotes" & ActiveSheet.Range("B2").Value & " Quote.pdf", _

Quality
:=xlQualityStandard, _
IncludeDocProperties
:=True, _
IgnorePrintAreas
:=False, _
OpenAfterPublish
:=False
End With
end sub</code>
It took me a while to figure out the above (which im sure is really simple) but i am still learning,
So I think I need a Case and If and Else to make this happen but I am not sure how to structure it and create folders at the same time
Can anyone help me with this?Thanks
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,223,894
Messages
6,175,250
Members
452,623
Latest member
Techenthusiast

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