ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheets Add fails with SP1 of Excel 2003 (https://www.excelbanter.com/excel-programming/314153-worksheets-add-fails-sp1-excel-2003-a.html)

OliverS

Worksheets Add fails with SP1 of Excel 2003
 
Adding a new worksheet using the Worksheets Add method throws an exception
with error code 0x80010105 (RPC_E_SERVERFAULT - "The server threw an
exception.").
The code (in C++) looks like this:

Worksheets sheets;
sheets = book.GetWorksheets();
sheet = sheets.Add(covOptional, covOptional, covOptional, covOptional);

This code works without problems with Excel 2000 and 2002.
It also worked with Office 2003 without SP1. After installing SP1 however
the program fails the way described above.

I am running Windows XP SP1 + Office Professional Edition 2003.
Thanks


OliverS

Worksheets Add fails with SP1 of Excel 2003
 
After some investigation the problem seems to be related to the fact that
Excel is not the active view, when the Worksheet is added. With SP1 installed
this method now fails.

I produced a small example program, an MDI application created with MFC,
where one of the views is an in-place activated Excel workbook.
A command in the File menu calls the Worksheets Add method on the Excel
view. The example demonstrates that this method fails if Excel is not the
active view.
This worked for all previous version of Excel, but not anymore with SP1
installed.

Unfortunately the workaround to always activate the Excel view during this
operation, is not possible in our real application.


"OliverS" wrote:

Adding a new worksheet using the Worksheets Add method throws an exception
with error code 0x80010105 (RPC_E_SERVERFAULT - "The server threw an
exception.").
The code (in C++) looks like this:

Worksheets sheets;
sheets = book.GetWorksheets();
sheet = sheets.Add(covOptional, covOptional, covOptional, covOptional);

This code works without problems with Excel 2000 and 2002.
It also worked with Office 2003 without SP1. After installing SP1 however
the program fails the way described above.

I am running Windows XP SP1 + Office Professional Edition 2003.
Thanks


James

Worksheets Add fails with SP1 of Excel 2003
 
adding this for posterity mostly because i have the identical problem and
cant find any documentation anywhe
this code replaces the "sheets.add" code that throws the error in excel 2003
with sp1:
'xlb is the workbook
xlb.Parent.Windows(xlb.Name).Visible = True
Set xls = xlb.Sheets.Add(After:=xlb.Sheets(xlb.Sheets.Count) )
xlb.Parent.Windows(xlb.Name).Visible = False

i havent tested it to see if it works in excel 97-2002, but it should

"OliverS" wrote:

Adding a new worksheet using the Worksheets Add method throws an exception
with error code 0x80010105 (RPC_E_SERVERFAULT - "The server threw an
exception.").
The code (in C++) looks like this:

Worksheets sheets;
sheets = book.GetWorksheets();
sheet = sheets.Add(covOptional, covOptional, covOptional, covOptional);

This code works without problems with Excel 2000 and 2002.
It also worked with Office 2003 without SP1. After installing SP1 however
the program fails the way described above.

I am running Windows XP SP1 + Office Professional Edition 2003.
Thanks



All times are GMT +1. The time now is 04:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com