Save with variable path

TrixterDK

New Member
Joined
Jun 22, 2018
Messages
3
We are 2 person who open the same sharepoint file.
We both have our own onedrive and the files there.
So the path is not the same when we open the same file.
How do i save the file to my path and he to his path.
I have the following code that save both aas pdf and xlm

Sub Knap1_Klik()
'
' Knap1_Klik Makro
' Gem som
'


'
ChDrive "D"
ChDir "D:\Volstrup Golfcenter\Dokumenter - Dokumenter (1)\Rullegræs\Faktura"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=("Faktura") & Range("d4") & Chr(95) & Range("a7")


fname = ("Faktura") & Range("d4") & Chr(95) & Range("a7").Value
ActiveSheet.SaveAs Filename:=fname


End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi,

You can always use environ("UserName") to find out who logged on the current computer: -

Select Case Environ("UserName")

Case "Peter"
'set folder to Peters folder
Case "Paul"

'set folder to Pauls folder

Case Else
'set up a standard location for anyone else
End Select
 
Last edited:
Upvote 0
My question is, what does environ return when you test it on each pc should give different answers therefor can use an if statement or select case for different answers?

Try debug.print Environ("UserName") 'answer returned in the immediate window

This should give you who logged on

Or Try

debug.print Environ("COMPUTERNAME") 'to get the name of the PC. 'answer returned in the immediate window
 
Upvote 0
Thank that could work.
But what then if suddenly change my location? Then i need to copy the location ones again.
 
Upvote 0
You could create a table within excel that keeps note of who logs on and which machine used to log on. (very hidden if you like). Also perhaps when they last logged on as well!

With a combination of who signs on and with what computer you could show a message box asking question add this as new location? if not found.

I'm sure you can come up with a suitable answer to your solution
 
Upvote 0

Forum statistics

Threads
1,215,025
Messages
6,122,732
Members
449,093
Latest member
Mnur

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