Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

File Open to Current Document Folder

2 views
Skip to first unread message

Jimmy Gooding

unread,
Oct 9, 2001, 4:32:50 PM10/9/01
to
I'm looking for a way to have Word always open the folder in which the
current document resides.

Example:
1. I open document1.doc from the c:\document1 folder.
2. I open document2.doc from the c:\document2 folder.
3. I switch back to document1.doc and do a file > open. The Open
dialog box appears with the c:\document2 folder as the Look in box. I
want it to be the c:\document1 folder (i.e. where document1.doc - the
current document - resides).

If, at step 3, I do a File > Save As, and then hit escape and then
File > Open, it opens the dialog box with the c:\document1 folder as
the Look In box (which is what I want). Isn't there a way to write a
macro to do this? (I'm VBA challenged).

Thanks.
______________________________________________________________________________
Posted Via Binaries.net = SPEED+RETENTION+COMPLETION = http://www.binaries.net

Larry

unread,
Oct 9, 2001, 4:51:36 PM10/9/01
to
Hi Jimmy,

This macro opens the Open Dialog box to the folder of the active
document. I've also added the shift+tab command to move the focus to
the document window in the dialog box, saving a step. Because of the
presence of the SendKeys statement, this macro works if assigned to a
menu item, not a keystroke. I'd recommend putting it on the File menu.
If you don't care about having the focus changing automatically, you
could delete the SendKeys statement, and then the macro would work with
a keystroke. But it's pretty easy on the Folder menu. I underline the
F in the macro name and just press Alt+F, F to run it.

I also added a message to explain why the macro doesn't work if you try
to run it when the active document has not yet been named.

Larry


Sub OpenDialogBoxInCurrentFolder()

If ActiveDocument.Path <> "" Then
ChangeTo = ActiveDocument.Path
ChangeFileOpenDirectory (ChangeTo)
SendKeys "+{TAB}"
Application.Dialogs(wdDialogFileOpen).Show
Else
MsgBox "This is an unsaved document."
End If
End Sub


Jimmy Gooding

unread,
Oct 10, 2001, 9:00:48 AM10/10/01
to
Thanks, Larry. It works great!

______________________________________________________________________________

0 new messages