|
-
Oct 20th, 2004, 11:12 AM
#1
Thread Starter
Junior Member
Excel Crashes when trying to Open Word Document
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.
VB Code:
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
Last edited by recarv; Oct 21st, 2004 at 02:00 PM.
-
Oct 20th, 2004, 12:01 PM
#2
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.
VB Code:
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 20th, 2004, 12:51 PM
#3
Thread Starter
Junior Member
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.
-
Oct 20th, 2004, 01:08 PM
#4
Also, make sure you dont have any hidden instances or Word
running, left overs from debugging. Look in the Task manager
processes list.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|