Hi,
I've used a program (copied and pasted it from a Microsoft recommended site)
with the use of the windows API to sellect an excel spreadsheet, get is path,
with success, when I use the same, to open a word document it gives me a
'Bad file name error.
Is there a way to use the explorer to find a word document so that it can be
used in and expression like,
Set objDocs = objWord.Documents.Add(strwordTemplate)
where
strwordTemplate
is the path to the document.

Signature
Regards
Bill
Perry - 06 Apr 2007 10:44 GMT
[strwordTemplate] does this contain the full filename?
In other words, if you run below sequence, does the messagebox popup?
If Dir(strwordTemplate) = "" Then
MsgBox "File does not exists"
Else
Set objDocs = objWord.Documents.Add(strwordTemplate)
End if
--
Krgrds,
Perry
System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
> Hi,
> I've used a program (copied and pasted it from a Microsoft recommended
[quoted text clipped - 14 lines]
>
> is the path to the document.
justagrunt - 06 Apr 2007 23:20 GMT
Thanks Perry,
I get the message box after the API window has opened to select the file and
the selection has been made - "Bad File Name".
I will implement your valued comments and see where it takes me.

Signature
Best Regards
Bill (Happy esater from New Zealand)
> [strwordTemplate] does this contain the full filename?
> In other words, if you run below sequence, does the messagebox popup?
[quoted text clipped - 31 lines]
> >
> > is the path to the document.
Helmut Weber - 06 Apr 2007 13:41 GMT
I don't know about the explorer.
Possibly you don't need any api for what you want to do.
Try:
Sub Macro4()
Dim strFil As String
Dim strPth As String
Dim odlg As Dialog
Set odlg = Dialogs(wdDialogFileOpen)
With odlg
.Display
' doubleclick filename in listbox
strFil = .Name
strPth = WordBasic.FileNameInfo(.Name, 5)
End With
MsgBox strPth & strFil '!
End Sub

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
justagrunt - 06 Apr 2007 23:16 GMT
Thanks Helmut,
will implement and see if it works.

Signature
Best Regards
Bill (Happy Easter from New Zealand)
> I don't know about the explorer.
> Possibly you don't need any api for what you want to do.
[quoted text clipped - 14 lines]
> MsgBox strPth & strFil '!
> End Sub