I have a workbook that crashes when running certain macros (Error message "Automation Error Exception Occurred" and then Excel closes). I'm confused because it only crashes when I have other programs running while attempting to run the macro. Right now, I have 2 Internet Explorer windows, Outlook, and one other program open. If I try to run the macro Excel crashes. If I close all those other programs, the macro runs fine.
The macro involves opening a file on the network, copying all cells, pasting them to a specific worksheet within the workbook, then closing the workbook I copied from. It does this about ten times. It always crashes while trying to close the 2nd workbook (Workbooks("Allport.xls").Close).
Sub UpdateSMAModel()
'
'
Application.ScreenUpdating = False
Application.DisplayAlerts = False
RB = ActiveWorkbook.Name
ChDir "P:\Portfolios\SMA"
Workbooks.Open Filename:="P:\Portfolios\SMA\SMAModel.xls"
Cells.Select
Selection.Copy
Windows(RB).Activate
Sheets("SMA Model Hard Coded").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
Workbooks("SMAModel.xls").Close
Windows(RB).Activate
ChDir "P:\Portfolios"
Workbooks.Open Filename:="P:\Portfolios\Allport.xls"
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Windows(RB).Activate
Sheets("Allport").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
Workbooks("Allport.xls").Close
Windows(RB).Activate
ChDir "P:\Portfolios\SMA"
Workbooks.Open Filename:="P:\Portfolios\SMA\AllSMA.xls"
Application.CutCopyMode = False
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows(RB).Activate
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select
Windows("AllSMA.xls").Activate
ActiveWindow.Close
Windows(RB).Activate
'code continues but I cut it short
Display More
When I enabled alerts, I was able to find this error code as the macro crashed:
-2147417848 (80010108) The object invoked has disconnected from its clients.
I believe my problem is that I am using "Unqualified Code" (see website below)
http://support.microsoft.com/d…spx?scid=kb;en-us;Q319832
However, I am not sure how to "Qualify" my code. I'm not that advanced and the website above doesn't put it in simple enough terms for me to understand. I have 3 spreadsheets that all have this same problem (they crash sometimes, and run fine other times). I'm using a brand new dual core Dell computer, Windows XP, Excel 2003.
Thanking you in advance for your help or suggestions