Syntax for shared access to folder

MikeL

Active Member
Joined
Mar 17, 2002
Messages
488
Office Version
  1. 365
Platform
  1. Windows
Hello,
I currently have a line that exports to a shared folder. How can I substitute 'Washington' so that any users that have remote access to a PC can run this macro? I heard a suggestion of using a wildcard or ampersand but don't know if or how that would work.

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, QueryName, "C:\Users\washington\Shared Folder\ " & " .xlsx", True

Thanks in advance.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Well that is not doing anything?, there is no filename?

If the folder is shared they can access it (pun intended :) ), so just put the file in there?

If you are talking about a folder per user, then something along the lines of

Code:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, QueryName, "C:\Users\" & UserName & "\Shared Folder\ " & strFileName & ".xlsx", True
 
Upvote 0
If you are talking about a folder per user, then something along the lines of

Code:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, QueryName, "C:\Users\" & UserName & "\Shared Folder\ " & strFileName & ".xlsx", True

I think you will need Environ("UserName"), no? I'm not aware of a stock UserName variable and couldn't get one to return anything when tested in the Immediate Window.

VBA Code:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, QueryName, "C:\Users\" & Environ("UserName") & "\Shared Folder\ " & strFileName & ".xlsx", True
 
Upvote 0
I think you will need Environ("UserName"), no? I'm not aware of a stock UserName variable and couldn't get one to return anything when tested in the Immediate Window.

VBA Code:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, QueryName, "C:\Users\" & Environ("UserName") & "\Shared Folder\ " & strFileName & ".xlsx", True
They were just meant to be placeholders? I doubt the o/p has even thought of a strFileName? :(
 
Upvote 0
It would be a good idea to actually use a shared folder, such as one you create ( C:\MySharedFolder ) or one that exists ( C:\Users\Public\Documents ). Then you don't have to worry about usernames. The above suggestions would be an avenue as well, and you can always check out special folders https://ss64.com/vb/special.html (not really my favorite as I generally avoid most of those folders anyway but can be useful in some cases)
 
Upvote 0

Forum statistics

Threads
1,214,530
Messages
6,120,071
Members
448,943
Latest member
sharmarick

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