File path issue gets tougher

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,169
Office Version
  1. 2016
Platform
  1. Windows
Hello I have this issue here and I need help :

Code:
Sub pdfCreate  ()
Dim FolderPath As String 
FolderPath = ThisWorkbook.Path & "\PDF FILES"
ChDir ThisWorkbook.Path & "\PDF FILES"
Sheet10.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Sheet10.Range("F4").Text, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False 
End Sub

I want the files saved in that pdf files folder yet it keeps saving it in the documents folder.

I am sure I am messing up with something but can't see it yet.

Point that out for me please.

Thanks in advance
Kelly
 
what is the filepath of thisworkbook.path if its the documents folder then you need to change the file path and not use thisworkbook.path


The path is not to the documents folder. It's at where I am that "pdf files " folder
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
you posted thisworkbook.path, I'm asking what that is, I'm not entirely sure you should be using CHDIR.

I think you just want a different filepath which thisworkbook.path will not give you. If thisworkbook lives in the documents folder then to the documents folder you will go everytime until you change the path
 
Upvote 0
Include the file path in the export line.
 
Upvote 0
you posted thisworkbook.path, I'm asking what that is, I'm not entirely sure you should be using CHDIR.

I think you just want a different filepath which thisworkbook.path will not give you. If thisworkbook lives in the documents folder then to the documents folder you will go everytime until you change the path

The file is inside a folder on the drive D currently. It is not in anyway associated with the documents folder. I just don't know why not working .

It used to work fine before
I tried commenting out all the path in the code and saw that it was still saving to the documents folder which means my paths are not working. Though everything seems good.
 
Upvote 0
Code:
  Sheet10.ExportAsFixedFormat Type:=xlTypePDF, _
                              Filename:=ThisWorkbook.Path & "\PDF FILES\" & Sheet10.Range("F4").Text, _
                              Quality:=xlQualityStandard, _
                              IncludeDocProperties:=True, _
                              IgnorePrintAreas:=False, _
                              OpenAfterPublish:=False
 
Upvote 0
Go on line and look this up, there appears to be an issue for some people when they installed windows 10, something about making themselves an administrator
 
Upvote 0
ChDir doesn't change the drive, just the default path on the specified drive. So you either need to change the drive as well (ChDrive ThisWorkbook.Path), or specify the path completely (as shown).
 
Upvote 0
Code:
  Sheet10.ExportAsFixedFormat Type:=xlTypePDF, _
                              Filename:=ThisWorkbook.Path & "\PDF FILES\" & Sheet10.Range("F4").Text, _
                              Quality:=xlQualityStandard, _
                              IncludeDocProperties:=True, _
                              IgnorePrintAreas:=False, _
                              OpenAfterPublish:=False


Great!!!
Thanks a lot @shg

It worked like a miracle.
Kelly
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

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