Results 1 to 4 of 4

Thread: Excel Crashes when trying to Open Word Document

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Location
    Cambridge,MA
    Posts
    20

    Resolved 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:
    1. If Module1.dhFileExists("C:\instagram\Instagram_Manual.doc") Then
    2.         Dim wdapp As Word.Application
    3.         Dim wdDoc As Word.Document
    4.         Set wdapp = CreateObject("Word.Application")
    5.         wdapp.Visible = True
    6.         Set wdDoc = wdapp.Documents.Open("C:\instagram\Instagram_Manual.doc")
    7.         Set wdDoc = Nothing
    8.         Set wdapp = Nothing
    9.     Else
    10.         MsgBox "Manual was not found."
    11.         Exit Sub
    12.     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.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    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:
    1. Public Function OpenWordDoc()
    2. 'Add reference to MS Word xx.0 Object Library
    3.     Dim wdApp As Word.Application
    4.     Dim wdDoc As Word.Document
    5.    
    6.     If 1 = 1 Then
    7.         Set wdApp = CreateObject("Word.Application")
    8.         wdApp.Visible = True
    9.         Set wdDoc = wdApp.Documents.Open("D:\My Documents\Doc1.doc")
    10.         Set wdDoc = Nothing
    11.         Set wdApp = Nothing
    12.     Else
    13.         MsgBox "Manual was not found."
    14.         Exit Function
    15.     End If
    16.  
    17. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Location
    Cambridge,MA
    Posts
    20
    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.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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
  •  



Click Here to Expand Forum to Full Width