Macro to open same directory as last file opened?

C

Claudia

A week or so ago I posted requesting a code to open specific subdirectories.
Perry kindly replied with the following code which works perfectly (but, see
below code for my question):

Dim f As FileDialog
Set f = Application.FileDialog(msoFileDialogOpen)
With f
.InitialFileName = "W:\13\"
If .Show Then .Execute
End With

As I said, that works great - we have 15 subdirectories, and I have a button
to run a macro to open each subdirectory on each user's toolbar. So far, so
good. However a new problem has surfaced because of the macro: When the users
run the macro to open a directory and pull up a document, the File -> Open
command does not automatically open to the same subdirectory from which the
document was opened. It will open to whichever directory is specified in
their File Location options *or* to whichever subdirectory was last opened
using the File -> Open command.

Can I create a macro that will open the subdirectory that was originally
opened with my macro? If there is, then I will assign it to a button on each
user's toolbar, so they can click that instead of the File Open button.

Claudia Carvalho
 
P

Perry

Call the Macro 'FileOpen' and it will replace Word's builtin FileOpen macro.
-------------------------------------
Krgrds,
Perry

System parameters:
POS: WinXP SP2
MSO: MSOffice 2003 SP2
DEV: VS8 (dotnet)
 
C

Claudia

Perry said:
Call the Macro 'FileOpen' and it will replace Word's builtin FileOpen macro.

I had a feeling I didn't make myself clear. Sorry.

There are 15 macros. Each macro is assigned to open a different
subdirectory. Those work fine. Let me give some examples to illustrate the
problem. I click the "13" button to open the W:/13/ directory and type
"13-200.411" to open that subdirectory and pull up a document. But, I decide
that I need another document from 13-200.411, so I click File -> Open, but
instead of it opening up to 13-200.411 as it would if I had used File -> Open
to browse to 13-200.411, it just opens up to the W: root directory. Users
aren't liking this.

What I need is a code that will open the last directory opened with one of
my 15 macros. I don't want to replace the FileOpen command, as hopefully the
above explanation makes clear.

Claudia
 
C

Claudia

Never mind my first response - I inserted the code, just removing "13", and
saved it as the FileOpen command. So far, it works great! Thank you.

Claudia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top