ChDir

jebenexcel

Board Regular
Joined
Mar 16, 2018
Messages
59
Hello,

Why doesn't this work?
The error is in the line that starts with ChDir abc & ""...

Code:
abc = "C:\a\b\c"
f = Range("A1")


       Sheets("1").Select
[B]       ChDir abc & "\" & f & "\" & "\g"[/B]
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        "a" & "_" & f & "_" & Format(Now(), "dd.mm.yyyy") & ".pdf" _
        , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
        :=False, OpenAfterPublish:=False
 
Last edited:

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
What's the error message?

Note you don't really need to us ChDir at all there - you can simply specify the full path and file name in the following export line.
 
Upvote 0
error 76, path not found
So basically if I just remove ChDir and leave pšart of the path as a string it should work?
 
Upvote 0
error 76, path not found
So basically if I just remove ChDir and leave pšart of the path as a string it should work?

Yes


If you set filename to "C:\a\b\c" & "" & f & "" & "\g" & "a" & "_" & f & "_" & Format(Now(), "dd.mm.yyyy") & ".pdf"



Notice the extra "" after the "g"
 
Upvote 0
That is the gist but it sounds as though your path is invalid, so that will probably fail too! You need to make sure the path you specify actually exists.
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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