Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA - Open Folder Where .xls Resides


Group,
Another novice question. When I open a file I use the following
code. The first use of my spreadsheet always begins in a folder other
than where the files are located. Once I navigate to the folder where
my files are located, Excel remembers the path. Then each subsequent
opening and Excel opens that folder. Is there a way to always open the
folder where my spreadsheet is located? Assume my files are located in
folder c:\MPI .




fn2 = Application.GetOpenFilename("Current MPI File,*.mpi", 1,
"Select NEW MPI File To Open", , False)


Tony


--
ajocius
------------------------------------------------------------------------
ajocius's Profile: http://www.excelforum.com/member.php...o&userid=17695
View this thread: http://www.excelforum.com/showthread...hreadid=470534

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default VBA - Open Folder Where .xls Resides

Use the ChDir before the Application.GetOpenFilename dialog to set the
path.........

e.g.....

ChDir "C:\Nigel"
fn2 = Application.GetOpenFilename("Current MPI File,*.mpi", 1, _
"Select NEW MPI File To Open", , False)

--
Cheers
Nigel



"ajocius" wrote in
message ...

Group,
Another novice question. When I open a file I use the following
code. The first use of my spreadsheet always begins in a folder other
than where the files are located. Once I navigate to the folder where
my files are located, Excel remembers the path. Then each subsequent
opening and Excel opens that folder. Is there a way to always open the
folder where my spreadsheet is located? Assume my files are located in
folder c:\MPI .




fn2 = Application.GetOpenFilename("Current MPI File,*.mpi", 1,
"Select NEW MPI File To Open", , False)


Tony


--
ajocius
------------------------------------------------------------------------
ajocius's Profile:

http://www.excelforum.com/member.php...o&userid=17695
View this thread: http://www.excelforum.com/showthread...hreadid=470534



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default VBA - Open Folder Where .xls Resides

Maybe you must use ChDrive also
See how I use it here
http://www.rondebruin.nl/copy3.htm

It will restore the original path when it is done also



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Nigel" wrote in message ...
Use the ChDir before the Application.GetOpenFilename dialog to set the
path.........

e.g.....

ChDir "C:\Nigel"
fn2 = Application.GetOpenFilename("Current MPI File,*.mpi", 1, _
"Select NEW MPI File To Open", , False)

--
Cheers
Nigel



"ajocius" wrote in
message ...

Group,
Another novice question. When I open a file I use the following
code. The first use of my spreadsheet always begins in a folder other
than where the files are located. Once I navigate to the folder where
my files are located, Excel remembers the path. Then each subsequent
opening and Excel opens that folder. Is there a way to always open the
folder where my spreadsheet is located? Assume my files are located in
folder c:\MPI .




fn2 = Application.GetOpenFilename("Current MPI File,*.mpi", 1,
"Select NEW MPI File To Open", , False)


Tony


--
ajocius
------------------------------------------------------------------------
ajocius's Profile:

http://www.excelforum.com/member.php...o&userid=17695
View this thread: http://www.excelforum.com/showthread...hreadid=470534





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA - Open Folder Where .xls Resides


Gentlemen,
I guess my fingers were typing faster than my brain engaged. But
my application will sit on numerous engineers computers who are
connected to a network and who have different paths to their respective
Desktops. How am I able to open a folder from where my Excel file
resides. I know I didn't explain the original post as clearly. Please
ignore the c:\MPI.

Tony


--
ajocius
------------------------------------------------------------------------
ajocius's Profile: http://www.excelforum.com/member.php...o&userid=17695
View this thread: http://www.excelforum.com/showthread...hreadid=470534

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default VBA - Open Folder Where .xls Resides

See the code I use here
http://www.rondebruin.nl/copy3.htm#select

Example 6


--
Regards Ron de Bruin
http://www.rondebruin.nl


"ajocius" wrote in message
...

Gentlemen,
I guess my fingers were typing faster than my brain engaged. But
my application will sit on numerous engineers computers who are
connected to a network and who have different paths to their respective
Desktops. How am I able to open a folder from where my Excel file
resides. I know I didn't explain the original post as clearly. Please
ignore the c:\MPI.

Tony


--
ajocius
------------------------------------------------------------------------
ajocius's Profile: http://www.excelforum.com/member.php...o&userid=17695
View this thread: http://www.excelforum.com/showthread...hreadid=470534





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default VBA - Open Folder Where .xls Resides

Use ChDir and ChDrive together with thisworkbook.path (or
activeworkbook.path as appropriate).

Option Explicit

Sub testIt()
Dim SavedPathname As String

MsgBox Application.GetOpenFilename()
SavedPathname = CurDir

ChDir ThisWorkbook.Path
ChDrive ThisWorkbook.Path
MsgBox Application.GetOpenFilename()

ChDir SavedPathname
ChDrive SavedPathname
MsgBox Application.GetOpenFilename()
End Sub

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...

Group,
Another novice question. When I open a file I use the following
code. The first use of my spreadsheet always begins in a folder other
than where the files are located. Once I navigate to the folder where
my files are located, Excel remembers the path. Then each subsequent
opening and Excel opens that folder. Is there a way to always open the
folder where my spreadsheet is located? Assume my files are located in
folder c:\MPI .




fn2 = Application.GetOpenFilename("Current MPI File,*.mpi", 1,
"Select NEW MPI File To Open", , False)


Tony


--
ajocius
------------------------------------------------------------------------
ajocius's Profile:
http://www.excelforum.com/member.php...o&userid=17695
View this thread: http://www.excelforum.com/showthread...hreadid=470534


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
Identify the row in which a MAX number in a column resides BarDoomed Excel Worksheet Functions 7 June 5th 08 08:23 PM
VLOOKUP when a range resides in Column A rpalarea Excel Discussion (Misc queries) 1 June 19th 07 08:40 PM
XL 2007: Pivot Refresh slow when data resides in another workbook funnybroad Excel Discussion (Misc queries) 1 May 31st 07 07:31 AM
open file from folder save in new folder tim64[_3_] Excel Programming 20 June 17th 05 07:58 PM
Open files in folder - skip if already open Steph[_3_] Excel Programming 6 March 25th 05 06:49 PM


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

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

About Us

"It's about Microsoft Excel"