macro placing file in folder

smattiko83

New Member
Joined
Nov 22, 2019
Messages
3
Hi, I'm trying to run this piece of code. The folder path below exist but i do not have access to view it. Is there anyway I can still have the file go there if I can't? Thanks.


VBA Code:
    Sheets("smith").Select
    Sheets("smith").Copy
    ChDir "N:\Home\gsmith\Leave Balances\"
    Application.DisplayAlerts = False
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        "N:\Home\gsmith\Leave Balances\Gsmith.pdf", Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
        False
    ChDir "N:\Home\tjohn\Leave Balances\"
    Application.DisplayAlerts = False
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        "N:\Home\tjohn\Leave Balances\Gsmith.pdf", Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
        False
    ActiveWindow.Close
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Does the macro send you an error? what does the error say?
The Chdir instruction is not necessary.
It may be so:

VBA Code:
Sub test()
  Sheets("smith").Copy
  Application.DisplayAlerts = False
  ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "N:\Home\gsmith\Leave Balances\Gsmith.pdf", Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
    False
  Application.DisplayAlerts = False
  ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "N:\Home\tjohn\Leave Balances\Gsmith.pdf", Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
    False
  ActiveWindow.Close False
End Sub
 
Upvote 0
If you do not have write permissions for the folder, then you cannot save files to it.
 
Upvote 0
Does the macro send you an error? what does the error say?
The Chdir instruction is not necessary.
It may be so:

VBA Code:
Sub test()
  Sheets("smith").Copy
  Application.DisplayAlerts = False
  ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "N:\Home\gsmith\Leave Balances\Gsmith.pdf", Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
    False
  Application.DisplayAlerts = False
  ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "N:\Home\tjohn\Leave Balances\Gsmith.pdf", Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
    False
  ActiveWindow.Close False
End Sub
I get the run time error 75: path/file access
 
Upvote 0
That's right, as Fluff said, if you don't have permission to see, you don't have permission to write either. You should review this topic with the administrator where you are trying to write.
 
Upvote 0
That's right, as Fluff said, if you don't have permission to see, you don't have permission to write either. You should review this topic with the administrator where you are trying to write.
Thank you both for the reply. Just wanted to check and make sure there wasn't a work around.
 
Upvote 0
Unfortunately there is no option. I hope you can resolve the issue with the administrator
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,487
Members
448,967
Latest member
visheshkotha

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