ChDir path problem

grapevine

Board Regular
Joined
May 23, 2007
Messages
208
I have been using a macro successfully for sometime now, but I have just bought a new machine and I am running W10 and 365 E3 and now the macro will not see the path of the file

The files are all stored in the cloud (Office 365, OneDrive for Business) but are also synced with File Explorer
When i look at the path in Explorer it shows

C:\Users\mkd\OneDrive - Grapevine Computing Ltd\Tutoring\Earnings-MKD\Inv2019-2020

When i look at the properties within Excel it shows
https//grapevinecomputing-my.sharepoint.com/personal/mkd_grapevinecomputing_co_uk/Documents/Tutoring/Earnings-MKD/Inv2019-2020

the file path is used several time in the macro so I added it as a call in via ChDir
I have tried
HTML:
'FilePath = "C:\Users\mkd\OneDrive - Grapevine Computing Ltd\Tutoring\Earnings-MKD\Inv2019-2020"
FilePath = "//grapevinecomputing-my.sharepoint.com/personal/mkd_grapevinecomputing_co_uk/Documents/Tutoring/Earnings-MKD/Inv2019-2020"
'FilePath = "https//grapevinecomputing-my.sharepoint.com/personal/mkd_grapevinecomputing_co_uk/Documents/Tutoring/Earnings-MKD/Inv2019-2020"

but i cannot get the directory to be found. The first macro is as follows
HTML:
Sub PDFSave()
   
    ChDir _
        FilePath
   
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FilePath & "\" & InvNum _
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
        :=False, OpenAfterPublish:=False
End Sub
I always get run code 76.
I have tried googling, hence the different attempts at the file path, but I am at a lost as to how i write the file path. Any assistance greatly appreciated, Many thanks
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
if you
Dim test as string
Test = FilePath & "\ " & InvNum

debug print Test as step through to that with F8 and see if it looks right
 
Last edited:
Upvote 0
Unfortunately, it still could see the path, so i actually deleted the ChDir command and it worked ok using the full https: line.
Many thanks
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,874
Members
452,363
Latest member
merico17

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