pdf of ws not saving - error

Mr_Ragweed2

Board Regular
Joined
Nov 11, 2022
Messages
145
Office Version
  1. 365
Platform
  1. Windows
Hello all.
I am trying to save one worksheet from a workbook of many sheets as a pdf to a different destination. I found a code in this forum that works according to the thread. I will post it here:
VBA Code:
Dim Path As String
    Dim SaveAsStr As String
    
    Path = Sheets("Combined data").Range("D1").Value
    SaveAsStr = "https://blah blah.sharepoint.com/:f:/r/teams/nunya/Shared%20Documents/General/Sales%20Apps/Seed%20Orders?csf=1&web=1&e=xW6Z7s"

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
        Filename:=SaveAsStr & ".pdf", _
        OpenAfterPublish:=False

The problem is i am getting an error saying "Document not saved. The document may be open, or an error may have been encountered when saving."
The document is definitely open. I am executing the code from a userform button.
Do i need to save to a new workbook first?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,224,735
Messages
6,180,638
Members
452,992
Latest member
TokugawaIesuma

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