LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Server Throws Exception on Workbook.Close

I have a simple MS Word macro that opens up MS Excel files, grabs
tables or graphs and inserts them into the MS Word file. It works fine
on my computer (MS Windows 2000, MS Office 2000 SP3) and some of my
colleagues' (MS Windows 2000 and one MS Windows XP, MS Office 2000
SP3), but produces a runtime error on others' (MS Windows XP, MS Office
2000 SP3).
On trying to .Close certain files, we get a "Server threw an exception"
error: -2147417851 (80010105) on some systems.

I can provide more detailed code if need be, but this is the framework
....

' ... Subroutine
Public objExcel As Excel.Application '... have tried late-binding, with
Object
Public objWorkbook As Excel.Workbook
Private ExcelRunning As Boolean

Sub HookExcelObject()
On Error GoTo ExcelNotRunning
ExcelRunning = True
Set objExcel = GetObject(, "Excel.Application")
Exit Sub
ExcelNotRunning:
ExcelRunning = False
Set objExcel = CreateObject("Excel.Application")
End Sub

Sub UnhookExcelObject()
If Not ExcelRunning Then
objExcel.Quit
End If
Set objExcel = Nothing
End Sub

' ... Main Module, behind a form
Call HookExcelObject

strFile = "c:\file_1.xls"
Set objWorkbook = objExcel.Workbooks.Open(FileName:=strFile,
Updatelinks:=False, ReadOnly:=True)
objWorkbook.Sheets(strSheet).Range(strRange).Copy
objWorkbook.Close SaveChanges:=False

strFile = "c:\file_2.xls"
Set objWorkbook = objExcel.Workbooks.Open(FileName:=strFile,
Updatelinks:=False, ReadOnly:=True)
objWorkbook.Sheets(strSheet).Range(strRange).Copy
objWorkbook.Close SaveChanges:=False ' <<< CRASH, BANG, WALLOP!

Set objWorkbook = Nothing
Call UnhookExcelObject

If I halt the code at the .Close line, I can probe the two objects
fine.

? TypeName(objExcel), TypeName(objWorkbook)
Application Workbook
? objExcel.ActiveWorkbook.Name, objWorkbook.ActiveSheet.Name
my_workbook.xls my_Sheet
objExcel.Visible = True
objWorkbook.Activate
objWorkbook.Close SaveChanges:=False
<BOOOOOOOM

objWorkbook.Saved = True
objWorkbook.Close
<BOOOOOOOM

objExcel.Visible = True
objWorkbook.Close(False)
<BOOOOOOOM

Could this be a MS Window XP thing ?
Any possible pointers?
thanks
jON

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel throws -2147417851 (80010105) The server threw an exception. for no apparent reason Lars-Erik Aabech Excel Programming 2 September 18th 06 05:28 AM
Copy a worksheet throws "Exception from HRESULT: 0x800A03EC." i3tech Excel Programming 4 August 15th 06 01:37 PM
get_Range function throws an exception Mikil Excel Programming 0 May 25th 06 03:12 PM
Excel throws exception if cell being edited Pixeled Excel Programming 2 September 6th 05 07:24 PM
Chart.Export throws COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC. Steven Excel Programming 1 November 5th 03 06:59 PM


All times are GMT +1. The time now is 02:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"