The last line of this code puts EXCEL into some kind of continuous loop

Mackeral

Board Regular
Joined
Mar 7, 2015
Messages
249
Office Version
  1. 365
Platform
  1. Windows
When my program executes the last line of this code, it puts Excel into a seemingly endless loop. The only to do at this point is just kill the program with Task Manager.

Anybody know what's going on or how to fix it?

Code:
Sub OpenDoc(File_Name)    ' Open a file.
    ' 9/25/17 Copied from Microsoft. WML
    
    Dim objWord As Object
    Dim objDoc As Object
    Dim blnStart As Boolean
    
    ' See if Word is already running; if not, start it
    Set objWord = GetObject(Class:="Word.Application")
    If objWord Is Nothing Then
        Set objWord = CreateObject(Class:="Word.Application")
        If objWord Is Nothing Then
            MsgBox "Can't start Word.", vbExclamation
            Exit Sub
        End If
        blnStart = True
    End If
    On Error GoTo ErrHandler
    
    ' Open document
    ' File_Name = "E:\Downloads\Activity (12).cvs" <-- legit ptr
    Set objDoc = objWord.Documents.Open(FileName:=File_Name)
.
.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,223,887
Messages
6,175,199
Members
452,617
Latest member
Narendra Babu D

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top