Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Opening files - macro
Help Needed.
I had developed a macro that was used by myself, however now the macro needs to be utilised by others. The marco opens files, that have been exported from the corporate database. The files are saved automatically to the users C Drive eg. C:\Documents and Settings\"username €“ officer logged on"\help.xls The only difference is the username in the file path. Is there anyway that I can change the file path to automatically go to the correct file, without having to create a different macros for each user. Any help would be greatly appreciated. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Opening files - macro
Use the Environ("USERPROFILE") function to get the logged on user's path.
You can use code like MsgBox Environ("USERPROFILE") to see what it returns on any given machine and adjust your path accordingly. Code to do the save could be something like this: Sub TestFileSaveAs() Dim myPath As String myPath = Environ("USERPROFILE") & "\test.xls" Application.DisplayAlerts = False ThisWorkbook.SaveAs myPath Application.DisplayAlerts = True End Sub "Max2073" wrote: Help Needed. I had developed a macro that was used by myself, however now the macro needs to be utilised by others. The marco opens files, that have been exported from the corporate database. The files are saved automatically to the users C Drive eg. C:\Documents and Settings\"username €“ officer logged on"\help.xls The only difference is the username in the file path. Is there anyway that I can change the file path to automatically go to the correct file, without having to create a different macros for each user. Any help would be greatly appreciated. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Opening files - macro
Oops, you wanted to OPEN the workbook, not change it's saved location. Same
deal just different command to use the myPath developed: Workbooks.Open myPath "Max2073" wrote: Help Needed. I had developed a macro that was used by myself, however now the macro needs to be utilised by others. The marco opens files, that have been exported from the corporate database. The files are saved automatically to the users C Drive eg. C:\Documents and Settings\"username €“ officer logged on"\help.xls The only difference is the username in the file path. Is there anyway that I can change the file path to automatically go to the correct file, without having to create a different macros for each user. Any help would be greatly appreciated. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Opening Files - Macro | Excel Worksheet Functions | |||
Opening Macro Files | Excel Programming | |||
macro opening too many files at once. | Excel Programming | |||
Opening Files Using a Macro | Excel Discussion (Misc queries) | |||
Opening CSV files with VBA/macro | Excel Programming |