Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm automating a report where I have to pull data from a database and copy a template worksheet in the workbook and rename it for each 'campaign' i get back from the database.

 

When doing this, I get the following COMException: "The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))"

 

Error Code: -2147417851

 

The code I have at the moment:

   worksheet = DirectCast(workbook.Worksheets("(campaign name)"), Excel.Worksheet)
   Dim newWorksheet As Excel.Worksheet = DirectCast(workbook.Worksheets.Add(), Excel.Worksheet)
   worksheet.Copy(, newWorksheet)
   worksheet = DirectCast(workbook.Worksheets("(campaign name) (2)"), Excel.Worksheet)
   worksheet.Name = cmp.Description
   worksheet.Visible = Excel.XlSheetVisibility.xlSheetVisible

That's not what I started with... I've been trying different ways of copying and pasting, and it all gets me pretty much the same result...except sometimes I get a messagebox as well as the exception box that says the memory could not be read, or something like that.

 

Anyone have any clue what could be causing this?

 

The file isn't readonly, it isn't opened in readonly mode, and it is finding the '(campaign name)' worksheet...

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...