Hi,
Using Word2002, I have the following script which works OK. My problem is
that I have used the ChangeFileOpenDirectory command.
I would like the users directory to remain at whatever it was before they
run this macro.
So for instance if the user were to press Ctrl-O and the directory was
Y:\MyFiles then I would like them to be able to run the following macro and
for Y:\MyFiles to remain as the default directory when they press Ctrl-O.
What is the command/procedure for that (please)?

Sub proInputText()
Dim strAns As String
strAns = InputBox("Type the number of the" & Chr(13) & _
"paragraph you wish to insert", "Will Retrieval")
If strAns = "" Then
Exit Sub
Else
ChangeFileOpenDirectory "Y:\Masters\WILLS\"
Selection.InsertFile FileName:=strAns, Range:="", ConfirmConversions:= _
True, Link:=False, Attachment:=False
End If
End Sub

Re: ChangeFileOpenDirectory help by Steve

Steve
Thu Nov 06 10:59:02 CST 2003

Hi Rita,

Just capture the existing directory in a string variable before you run your
process and reset it at the end
Sub proInputText()
> Dim strAns As String

DIM strOldDir as String
strOldDir = Options.DefaultFilePath(wdDocumentsPath)

> strAns = InputBox("Type the number of the" & Chr(13) & _
> "paragraph you wish to insert", "Will Retrieval")
> If strAns = "" Then
> Exit Sub
> Else
> ChangeFileOpenDirectory "Y:\Masters\WILLS\"
> Selection.InsertFile FileName:=strAns, Range:="", ConfirmConversions:=
_
> True, Link:=False, Attachment:=False
> End If

ChangeFileOpenDirectory strOldDir

> End Sub

HTH and have a great day!

Steve Lang


"Rita King" <exritaex@hotmail.com> wrote in message
news:eN4vfTBpDHA.2584@TK2MSFTNGP09.phx.gbl...
> Hi,
> Using Word2002, I have the following script which works OK. My problem is
> that I have used the ChangeFileOpenDirectory command.
> I would like the users directory to remain at whatever it was before they
> run this macro.
> So for instance if the user were to press Ctrl-O and the directory was
> Y:\MyFiles then I would like them to be able to run the following macro
and
> for Y:\MyFiles to remain as the default directory when they press Ctrl-O.
> What is the command/procedure for that (please)?
>
> Sub proInputText()
> Dim strAns As String
> strAns = InputBox("Type the number of the" & Chr(13) & _
> "paragraph you wish to insert", "Will Retrieval")
> If strAns = "" Then
> Exit Sub
> Else
> ChangeFileOpenDirectory "Y:\Masters\WILLS\"
> Selection.InsertFile FileName:=strAns, Range:="", ConfirmConversions:=
_
> True, Link:=False, Attachment:=False
> End If
> End Sub
>
>
>