Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel2007 automation error - the server threw an exception

Status
Not open for further replies.

BenAir

Programmer
Mar 12, 2007
4
GB
Hi there:

My client application creates an excel file (using COPY TO (filename) TYPE XL5) then uses automation to do some reformatting.

This has always worked fine but, since upgrading to Excel 2007, the client now sees this error when VFP (version 7) attempts the automation:-

OLE Error Code 0x80010105: The server threw an exception


Here is the beginning of my automation code:-

oXL=CREATEOBJECT("Excel.Application")
oXL.displayalerts=.F.
oWB=oXL.Workbooks.add(filename)
oModel=oXL.Activesheet
oSheet=oModel
oSheet.Name="New Name"

But it doesn't get this far as the excel file has not had the worksheet name changed.

Any ideas people please?
 
Your code threw an error in my xl 2003.
I changed the code a bit to just add a new workbook, then immediately name it by saving as, then proceeded to change the name of the sheet in the workbook and it seems to work.

"not tested in 2007"
Code:
LOCAL filename          &added
filename=[this.xls]     &added

oXL=CREATEOBJECT("Excel.Application")
oxl.visible= .t.         &added to see whats going on
oXL.displayalerts=.F.
oWB=oXL.Workbooks.add()   &changed
owb.SAVEAS(filename)      &added
oModel=oXL.Activesheet
oSheet=oModel
oSheet.Name="New Name"
wjwjr

This old world keeps spinning round - It's a wonder tall trees ain't layin' down
 
I've had exactly the same error, and have been notified of a solution but not yet had time to confirm it myself. In my case the 'server exception' was thrown when running the 'SaveAs()' function inside Excel 2003. It worked with the majority of users with XL2003 but not a few others. It is resolved (apparently) by updating Office 2003 with the latest service pack. Sorry I'm not sure what the latest service pack is for 2003 but hopefully it may do the trick for you. I'll post again when I can be more certain about this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top