
Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
Hi Russ
For what it's worth, Perry's code runs for me in VBA in Word 2003 if I make
two tiny changes as follows: add the Dim statement to create the variable,
and choose .SelectedItems(1), not (0).
Dim sFileName As String
Dim d As FileDialog
Set d = Application.FileDialog(msoFileDialogOpen)
d.Title = "search textfiles"
d.Filters.Add "My Textfiles (*.txt)", "*.txt"
d.FilterIndex = d.Filters.Count
If d.Show Then
sFileName = d.SelectedItems(1)
End If
Hope this helps.
Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
> What version of VBA does this code work with? Does a reference to a
> library
[quoted text clipped - 34 lines]
>>>
>>> Bear
Russ - 27 Jun 2007 17:55 GMT
Shauna,
Thanks for the reply.
It must be the version of VBA.
The macro doesn't seem to work on Word 97 at work or MacWord 2004 at home.
An error message highlights 'd as FileDialog' and says 'User-defined type
not defined'.
> Hi Russ
>
[quoted text clipped - 58 lines]
>>>>
>>>> Bear

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
Shauna Kelly - 28 Jun 2007 08:33 GMT
Hi Russ
The FileDialog object wasn't invented till about Word 2002. Before that,
there was no equivalent. Look at the VBA section at http://www.word.mvps.org
for alternatives that will work in Word 97.
Hope this helps.
Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
> Shauna,
> Thanks for the reply.
[quoted text clipped - 68 lines]
>>>>>
>>>>> Bear
Russ - 30 Jun 2007 02:34 GMT
Thanks Shauna,
I have been using the alternatives in Word97 and the workaround to be able
to pick multiple items through code. I was hoping that a simple reference in
Word97 would allow me to use the newer FileDialog object that allows titles,
selecteditems, filters, etc.
> Hi Russ
>
[quoted text clipped - 79 lines]
>>>>>>
>>>>>> Bear

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID