Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.general
|
|||
|
|||
![]()
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) |
#2
![]()
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.general
|
|||
|
|||
![]()
if this code is in Excel, then use
strWdDoc = Application.GetOpenFilename() see help for additional arguments. -- Regards, Tom Ogilvy "Ed" wrote: 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) |
#3
![]()
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.general
|
|||
|
|||
![]()
On May 24, 8:20 am, Tom Ogilvy
wrote: if this code is in Excel, then use strWdDoc = Application.GetOpenFilename() Thank you, Tom!! That was it! Ed |
#4
![]()
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.general
|
|||
|
|||
![]()
Heads up on:
Application.FileDialog() from Office XP up (so both Excel- as well as Word 2003) check out http://support.microsoft.com/kb/288543 Dim fd As FileDialog Set fd = Application.FileDialog() ....bla -- Krgrds, Perry System: Vista/Office Ultimate VS2005/VSTO2005 SE "Ed" schreef in bericht oups.com... 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) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
open word from excel...file does not exist error | Excel Programming | |||
Excel Hyperlink doesn't open Word doc the same way as Word does | Excel Discussion (Misc queries) | |||
Trying to open Excel/Word files error message "Unable to read file | Excel Discussion (Misc queries) | |||
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 | Excel Programming | |||
Graph Excel Selection, Open Word File, Embed Graph Into Word | Excel Programming |