|
Declare Function CoRegisterMessageFilter Lib "OLE32.DLL"
(ByVal lFilterIn As Long, ByRef lPreviousFilter) As Long
Sub RunMyProgram()
Dim xlApp As Excel.Application, lMsgFilter As Long
Const xlPath = "C:\Processes"
'Remove the message filter before passing the control to the Excel Application below
CoRegisterMessageFilter 0&, lMsgFilter
'Continue code below
Set xlApp = New Excel.Application
With xlApp
.DisplayAlerts = False
.Workbooks.Open xlPath & "\xlFile.xls", 0, True
.Run "xlFile.xls!xlProcess"
While .Workbooks.Count
.ActiveWorkbook.Close False
.Quit
End With
'Restore the message filter
CoRegisterMessageFilter lMsgFilter, lMsgFilter
End Sub |