Multiuser save to Desktop folder with macro

Phillip23

New Member
Joined
Mar 11, 2021
Messages
3
Office Version
  1. 2016
  2. 2013
  3. 2010
Platform
  1. Windows
Hi,

I need help with the below VBA. I have recently taken over the management of a file we use daily as a flight planning program.
My issue is we are multiple users on different desktops, the macro is set up to save to a specific shared folder on the master pc.

I need it to save to the "C:\User\#######\Desktop\Daily Flights" folder of the user(####) currently using the file, basically a dynamic save path. The workbook is copied to and opened from the users "Desktop\Daily Flights" Folder
The issue is the code in the VBA macro cannot be changed too much as there are nearly 700 macros in this workbook and they are mostly connected. Is there a string that can enable me to make this a dynamic save path macro?

Sub Save_Send_Pilots()

'
' Save_Send_Pilots Macro
'

'
Call FONTINVISIBLE

Application.ScreenUpdating = False

Dim filename As String

filename = Range("ay27").Value

ActiveWorkbook.SaveAs ("C:\Users\bowyerm\Desktop\Daily Flights\ " & filename & ".xlsm")

Application.Dialogs(xlDialogSendMail).Show

Application.DisplayAlerts = False
'ActiveWorkbook.SaveAs ("C:\Users\bowyerm\Desktop\Daily Flights\ " & filename & ".xlsm")

Application.DisplayAlerts = True

Sheets("route planner sheet").Select
Range("g4").Select

Application.ScreenUpdating = True

'Call FONTDARK

End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Do you want to get the Username?
Dim UN as string
UN = Environ("Username")
 
Upvote 0
Do you want to get the Username?
Dim UN as string
UN = Environ("Username")
Hi thanks for the reply, I know the usernames, the problem is when I run the macro with
ActiveWorkbook.SaveAs ("C:\Users\" & Environ("userprofile") & "\Desktop\Daily Flights\ " & filename & ".xlsm")

It returns an error and I have to debug.
I am just starting to learn VBA, it is a completely new experience for me, however I can usually figure things out quite quickly.
The ##### in the example were just to show that the Usernames are different on the computers we use. Sorry for not making it clear. Your help is appreciated.
 

Attachments

  • Capture.JPG
    Capture.JPG
    56.6 KB · Views: 21
Upvote 0
Environ("UserProfile") has "C:\Users\Username".
ActiveWorkbook.SaveAs (Environ("userprofile") & "\Desktop\Daily Flights\ " & filename & ".xlsm")

Please try this one.
 
Upvote 0
Solution
Thank you, Thank you, Thank you,

Works great, just tested on 3 user profiles.
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

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