E
Ed
I'm using WOrd and Excel 2003. I'm trying to open a Word document
with the following code. I get an error on the line that should
return the FileNameInfo. It's just a message box with no text and an
X in a red circle - no Debug, just Okay and the code stops. Yes, I
have a reference to the Word library.
What did I do wrong?
Ed
'***********************
Dim bolAgain As Boolean
bolAgain = False
Stop
On Error Resume Next
Set WdAp = Word.Application
If WdAp Is Nothing Then
Set WdAp = New Word.Application
End If
On Error GoTo 0
WdAp.Visible = True
Set WdDlg = WdAp.Dialogs(wdDialogFileOpen)
Do
With WdDlg
If .Display <> -1 Then
strWdDoc = ""
Else
strWdDoc = WordBasic.FileNameInfo$(.Name, 1) '<< error here!!
End If
End With
If strWdDoc = "" Then
If MsgBox("You didn't choose a document." & vbCrLf & _
"Please try again, or choose Cancel to quit.", vbOKCancel)
= vbCancel Then
Exit Sub
Else
bolAgain = True
End If
End If
Loop While bolAgain = True
Set WdDoc = WdAp.Documents.Open(strWdDoc)
with the following code. I get an error on the line that should
return the FileNameInfo. It's just a message box with no text and an
X in a red circle - no Debug, just Okay and the code stops. Yes, I
have a reference to the Word library.
What did I do wrong?
Ed
'***********************
Dim bolAgain As Boolean
bolAgain = False
Stop
On Error Resume Next
Set WdAp = Word.Application
If WdAp Is Nothing Then
Set WdAp = New Word.Application
End If
On Error GoTo 0
WdAp.Visible = True
Set WdDlg = WdAp.Dialogs(wdDialogFileOpen)
Do
With WdDlg
If .Display <> -1 Then
strWdDoc = ""
Else
strWdDoc = WordBasic.FileNameInfo$(.Name, 1) '<< error here!!
End If
End With
If strWdDoc = "" Then
If MsgBox("You didn't choose a document." & vbCrLf & _
"Please try again, or choose Cancel to quit.", vbOKCancel)
= vbCancel Then
Exit Sub
Else
bolAgain = True
End If
End If
Loop While bolAgain = True
Set WdDoc = WdAp.Documents.Open(strWdDoc)