Im 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:
Thats not what I started with... Ive 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 isnt readonly, it isnt opened in readonly mode, and it is finding the (campaign name) worksheet...
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:
Code:
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
Anyone have any clue what could be causing this?
The file isnt readonly, it isnt opened in readonly mode, and it is finding the (campaign name) worksheet...