Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,203
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,203
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening Files - Macro Max2073 Excel Worksheet Functions 1 December 10th 09 06:06 AM
Opening Macro Files VBA-PA[_2_] Excel Programming 6 August 12th 09 11:27 PM
macro opening too many files at once. SteveDB1 Excel Programming 1 June 25th 08 11:52 PM
Opening Files Using a Macro Mark Costello[_2_] Excel Discussion (Misc queries) 0 January 29th 08 03:48 PM
Opening CSV files with VBA/macro Vasco[_2_] Excel Programming 3 August 12th 03 12:18 PM


All times are GMT +1. The time now is 08:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"