vbaamateur1

New Member
Joined
Dec 8, 2017
Messages
3
I have a simple macro on an excel sheet where at the click of a button, it changes the page into a pdf.

Currently, the path is as such:
Sub savereport()
'
' savereport Macro
'
Sheets("Print Preview").Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\E233761\Downloads\WeeklyReport.pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True
End Sub


It works fine on my laptop but when I send it to a colleage it does not work, which makes sense because the path is trying to save it to my downloads. What path do I write to get it to save onto the downloads of whoever the user is?
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hi & welcome to the board.
Try this
Code:
"C:\Users\" & Environ("Username") & "\Downloads\WeeklyReport.pdf"
 
Upvote 0
Hi Fluff, thank you!

Shall I copy paste this directly or would be need to put a sub in for the "username" section?
 
Upvote 0
Just replace your filepath/name with what I supplied.
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,216,070
Messages
6,128,613
Members
449,460
Latest member
jgharbawi

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