PDA

Click to See Complete Forum and Search --> : Excel Crashes when trying to Open Word Document


recarv
Oct 20th, 2004, 11:12 AM
Hello,

I've got a problem where I'd like to have a word document open from Excel, It seems that I can start Word alright, but any attempt to open a file causes a crash. This makes me think I have the syntax wrong or something. Please help.


If Module1.dhFileExists("C:\instagram\Instagram_Manual.doc") Then
Dim wdapp As Word.Application
Dim wdDoc As Word.Document
Set wdapp = CreateObject("Word.Application")
wdapp.Visible = True
Set wdDoc = wdapp.Documents.Open("C:\instagram\Instagram_Manual.doc")
Set wdDoc = Nothing
Set wdapp = Nothing
Else
MsgBox "Manual was not found."
Exit Sub
End If


If I comment out the Set wdDoc = wdapp.Documents.Open("file") line, Word opens fine. If I don't, I have to send an error report to the great bit bucket in the sky that is Microsoft Development.

Please advise.

R

RobDog888
Oct 20th, 2004, 12:01 PM
Well this worked for me. I bypassed the file exists test and
added a reference to Word. Your code should work for you unless
there could be an issue with Word? Try doing a Office Update for
the latest patches and service packs. What version of Office are
you running?

This worked for me.
Public Function OpenWordDoc()
'Add reference to MS Word xx.0 Object Library
Dim wdApp As Word.Application
Dim wdDoc As Word.Document

If 1 = 1 Then
Set wdApp = CreateObject("Word.Application")
wdApp.Visible = True
Set wdDoc = wdApp.Documents.Open("D:\My Documents\Doc1.doc")
Set wdDoc = Nothing
Set wdApp = Nothing
Else
MsgBox "Manual was not found."
Exit Function
End If

End Function

recarv
Oct 20th, 2004, 12:51 PM
At least I know I'm not crazy. I'm using Office 2003. Sometimes it works (maybe one in 30 tries) but all other times it just crashes.

I'll update my office and see if it gets fixed. Lord knows I've submitted bug reports every single time in an effort to get the problem recognized.

The fileExists functions is just a jazzed up Len(Dir ) setup.

RobDog888
Oct 20th, 2004, 01:08 PM
Also, make sure you dont have any hidden instances or Word
running, left overs from debugging. Look in the Task manager
processes list.