VBA create PDF in team OndeDrive

junkforhr

Board Regular
Joined
Dec 16, 2009
Messages
115
Office Version
  1. 365
Platform
  1. Windows
I have the following code to create a PDF and save this PDF to a folder (input in sheet "Menu" and cell "A4").

We have a team OneDrive and I've tried simply input the URL in "Menu" and cell "A4 without success. Is there something else I should be doing?

Thanks in advance.


VBA Code:
Sub PDFPrintALL()

Dim ReportPath As Variant
    Dim ReportName As Variant
    Dim ToPrint As Variant
    Dim strSheet As Variant
 
  
    Set ReportPath = Sheets("Menu").Range("A5")
    Set ReportName = Sheets("Menu").Range("A3")
    Set ToPrint = Sheets("Menu").Range("A4")
    strSheet = Sheets("Menu").Range("A6")
 
    
  Sheets(strSheet).Activate
  
  
    On Error Resume Next
    With ActiveSheet
    .PageSetup.PrintArea = ToPrint
    .ExportAsFixedFormat Type:=xlTypePDF, _
    Filename:=ReportPath & ReportName & ".PDF", _
    Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, _
    OpenAfterPublish:=True
    On Error Resume Next
    
    End With
MsgBox "                                  PDF document:" & vbCrLf & "File Name:    " _
& ReportName & vbCrLf & vbCrLf & "                                  Has been created and has been saved to:" _
& vbCrLf & v
End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
I could be wrong, but I don't believe that the ExportAsFixedFormat method (or the SaveAs method) allows you to simply save to a URL address. Especially if it's a OneDrive address, because ordinarily when you transfer data via HTTPS (to an API with the POST method, for example) or by FTP, you would need to provide your credentials, etc. The easier way of saving something to OneDrive is to have that account mapped to a local drive, and then it would just be a matter of saving it to a local address. Then the OneDrive Desktop service running in the background takes care of the credentials and data transfer stuff for you.
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,283
Members
449,075
Latest member
staticfluids

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