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

Mackeral

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

Forum statistics

Threads
1,086,029
Messages
5,387,363
Members
402,056
Latest member
2368hewes

Some videos you may like

This Week's Hot Topics

Top