Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default File Path - Macros

Need some help.

I developed a macro that was used by myself, however the macro now needs to
be shared.

The macro opens files that are located in my C:\document and
settings\max28052. These files are saved automatically once exported from
the corporate database. The file is automatically named - they always have
the same name regardless of the officer.

Is there a way that I can change the macro to open the required files
without stating the full path (as it changes) eg. instead of c:\document and
settings\max28052\help.xls that it opens the logged on users eg. c:\document
and settings\"officers name"\help.xls.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default File Path - Macros


I you open a dos widnow and type SEt you will see all the user
environmental paraters. On WinXP go to

Start - Run
In run box type : cmd.exe

A dos window opens and then type : Set


In Vista go to Start and do a search for cmd.exe. follow instructions
above


The VBA code wil be something like this

UserProfile = environ("Userprofile")
Helpfile = Userprofile & "\help.xls"


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=160024

Microsoft Office Help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default File Path - Macros

Perhaps:

Sub officer()
Dim s1 As String, s2 As String, s3 As String
s1 = "C:\Documents and Settings\"
s2 = Environ("Username")
s3 = "\help.xls"
Workbooks.Open Filename:=s1 & s2 & s3
End Sub

--
Gary''s Student - gsnu200909


"Max2073" wrote:

Need some help.

I developed a macro that was used by myself, however the macro now needs to
be shared.

The macro opens files that are located in my C:\document and
settings\max28052. These files are saved automatically once exported from
the corporate database. The file is automatically named - they always have
the same name regardless of the officer.

Is there a way that I can change the macro to open the required files
without stating the full path (as it changes) eg. instead of c:\document and
settings\max28052\help.xls that it opens the logged on users eg. c:\document
and settings\"officers name"\help.xls.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default File Path - Macros

Max,

Something like this may work

MyPath = CreateObject("WScript.Shell").Specialfolders("MyDo cuments")

or you can build the path

MyPath = "C:\documents and settings\" & Environ("Username") & "\" & "
Help.xls"

Mike

"Max2073" wrote:

Need some help.

I developed a macro that was used by myself, however the macro now needs to
be shared.

The macro opens files that are located in my C:\document and
settings\max28052. These files are saved automatically once exported from
the corporate database. The file is automatically named - they always have
the same name regardless of the officer.

Is there a way that I can change the macro to open the required files
without stating the full path (as it changes) eg. instead of c:\document and
settings\max28052\help.xls that it opens the logged on users eg. c:\document
and settings\"officers name"\help.xls.

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
File Path Too Long? Not Anymore! Check out Long Path Tool Max Loger Excel Discussion (Misc queries) 1 March 24th 17 07:59 AM
path to macros being changed Risky Dave Excel Programming 8 May 31st 09 07:50 PM
Formula too long - new file path is shorter than old file path - Excel 2003 Greg J Excel Worksheet Functions 1 November 22nd 06 05:16 PM
if i save as the excel file, macros path changed Selim Ozbas Excel Programming 3 October 9th 06 07:26 PM
Moved file, changed path, macros don't work donbowyer Excel Programming 3 May 22nd 06 08:27 AM


All times are GMT +1. The time now is 02:36 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"