|
| View previous topic :: View next topic |
| Author |
Message |
Kathryn Pundt Guest
|
Posted: Thu Dec 20, 2007 5:11 pm Post subject: Word 2003: Need macro to stop redirecting where to find a fi |
|
|
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? |
|
| Back to top |
|
 |
Google Sponsor

|
Posted: Thu Dec 20, 2007 5:11 pm Post subject: Advertisement |
|
|
|
|
| Back to top |
|
 |
fumei via OfficeKB.com Guest
|
Posted: Thu Dec 20, 2007 7:11 pm Post subject: Re: Word 2003: Need macro to stop redirecting where to find |
|
|
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.
Kathryn Pundt wrote:
| Quote: | 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?
|
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200712/1 |
|
| Back to top |
|
 |
Kathryn Pundt Guest
|
Posted: Thu Dec 20, 2007 7:23 pm Post subject: Re: Word 2003: Need macro to stop redirecting where to find |
|
|
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""", _
"fumei via OfficeKB.com" wrote:
| Quote: | 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.
Kathryn Pundt wrote:
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?
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200712/1
|
|
|
| Back to top |
|
 |
Kathryn Pundt Guest
|
Posted: Fri Dec 21, 2007 5:53 pm Post subject: Re: Word 2003: Need macro to stop redirecting where to find |
|
|
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
"Kathryn Pundt" wrote:
| Quote: | 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""", _
"fumei via OfficeKB.com" wrote:
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.
Kathryn Pundt wrote:
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?
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200712/1
|
|
|
| Back to top |
|
 |
Graham Mayor Guest
|
Posted: Sat Dec 22, 2007 1:08 pm Post subject: Re: Word 2003: Need macro to stop redirecting where to find |
|
|
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
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Kathryn Pundt wrote:
| Quote: | 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
"Kathryn Pundt" wrote:
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""", _
"fumei via OfficeKB.com" wrote:
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.
Kathryn Pundt wrote:
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?
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200712/1 |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|