Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2007

Tip: Looking for answers? Try searching our database.

Word 2003: Need macro to stop redirecting where to find a file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kathryn Pundt - 20 Dec 2007 17:11 GMT
I create a macro, a simple one to open a file from a directory.  If I happen
to run another macro that finds a file from a different directory, other
macros are redirected to a wrong directory.  No matter how many times I
recreate the macro, the path is removed from the macro after I run a
different macro.  Most of my macros are simply to open a file.  I have put
them in a pulldown menu on my toolbar.  How can I make my macros remain as I
have created them?
fumei - 20 Dec 2007 19:11 GMT
I suspect you are using ChangeFileOpenDirectory.  Stop doing that, if
possible.  If you are opening an explicit file, there is no need to alter
ChangeFileOpenDirectory.  Just open the file by its path.

ChangeFileOpenDirectory changes the.....file open directory.  It remains
whatever you set it at, until you set it for something else.

Either that, and this is a good "best practice", when you change something,
at the end of your procedure, change it back.

>I create a macro, a simple one to open a file from a directory.  If I happen
>to run another macro that finds a file from a different directory, other
[quoted text clipped - 3 lines]
>them in a pulldown menu on my toolbar.  How can I make my macros remain as I
>have created them?
Kathryn Pundt - 20 Dec 2007 19:23 GMT
So, I would type in the macro:

Documents.Open FileName:="""00 - Prosecution Instructions.doc""", _

or

"Y:\Kathryn\INSTRUCT - Prosecution\"
Documents.Open FileName:="""00 - Prosecution Instructions.doc""", _

> I suspect you are using ChangeFileOpenDirectory.  Stop doing that, if
> possible.  If you are opening an explicit file, there is no need to alter
[quoted text clipped - 13 lines]
> >them in a pulldown menu on my toolbar.  How can I make my macros remain as I
> >have created them?
Kathryn Pundt - 21 Dec 2007 17:53 GMT
I went through all of my macros and did what was suggested, but they still do
not work.  Here is an example of the macro that opens a document.  My
question is, how does the macro know in what directory to look for the
document?

   Documents.Open FileName:="""Invoice template.doc""",
ConfirmConversions:= _
       False, ReadOnly:=False, AddToRecentFiles:=False,
PasswordDocument:="", _
       PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
       WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
End Sub

> So, I would type in the macro:
>
[quoted text clipped - 22 lines]
> > >them in a pulldown menu on my toolbar.  How can I make my macros remain as I
> > >have created them?
Graham Mayor - 22 Dec 2007 13:08 GMT
What you require (based on your earlier message) is presumably

Dim sPath As String
sPath = "Y:\Kathryn\INSTRUCT - Prosecution\"
Documents.Open FileName:=sPath & "Invoice template.doc"

ie include the path (here sPath) in the file open statement. Word always
retains the focus of the last used folder, so you need to include the path
in the open statement.

Also if as the filename suggests, this is a template, you may be better
saving it as a template and using file > new to open documents from it. eg

Dim sPath As String
sPath = Application.Options.DefaultFilePath(wdUserTemplatesPath) & "\"
Documents.Add Template:= _
       sPath & "Invoice Template.dot", NewTemplate:=False

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> I went through all of my macros and did what was suggested, but they
> still do not work.  Here is an example of the macro that opens a
[quoted text clipped - 41 lines]
>>> Message posted via OfficeKB.com
>>> http://www.officekb.com/Uwe/Forums.aspx/word-programming/200712/1

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.