LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.general
Ed Ed is offline
external usenet poster
 
Posts: 65
Default Error trying to open Word doc from Excel VBA

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)

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
open word from excel...file does not exist error tbaam Excel Programming 9 January 16th 07 03:34 PM
Excel Hyperlink doesn't open Word doc the same way as Word does duugg Excel Discussion (Misc queries) 2 October 12th 06 03:14 PM
Trying to open Excel/Word files error message "Unable to read file RobM Excel Discussion (Misc queries) 1 February 7th 05 08:11 PM
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed Frank Jones Excel Programming 2 June 15th 04 03:21 AM
Graph Excel Selection, Open Word File, Embed Graph Into Word Steve Excel Programming 0 November 17th 03 05:35 PM


All times are GMT +1. The time now is 11:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"