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

Mackeral

Board Regular
Joined
Mar 7, 2015
Messages
76
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)
.
.
 

Some videos you may like

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Watch MrExcel Video

Forum statistics

Threads
1,090,109
Messages
5,412,479
Members
403,429
Latest member
jmdesk20

This Week's Hot Topics

Top