Juan Velasquez
asked on
Error when trying to copy worksheet to another workbook
Hello,
I am trying to copy a worksheet and keep getting the following exception error
Exception from HRESULT: 0x800A03EC. It should be a simple matter of coping the worksheet returned by function GenerateWorksheet to the workbook created by Utilities.CreateWorkbook
I am trying to copy a worksheet and keep getting the following exception error
Exception from HRESULT: 0x800A03EC. It should be a simple matter of coping the worksheet returned by function GenerateWorksheet to the workbook created by Utilities.CreateWorkbook
Dim dpl As New List(Of DatasetPair)
'Try
Me.Cursor = Cursors.WaitCursor
Dim intSheetCount As Integer = 0
For i As Integer = 0 To lvMatchedDvid.Items.Count - 1
Dim dp As New DatasetPair
dp.DataVersionIdOne = lvMatchedDvid.Items(i).Text.ToString
dp.DataVersionIdTwo = lvMatchedDvid.Items(i).SubItems(1).Text.ToString
intSheetCount += 1
dp.SheetId = intSheetCount
dpl.Add(dp)
Next
Dim wb As Excel.Workbook = Utilities.CreateWorkbook()
Dim strFilePath As String = wb.Path.ToString & "\" & wb.Name.ToString
MessageBox.Show(strFilePath)
For Each dp As DatasetPair In dpl
Dim ws As New Excel.Worksheet
ws = GenerateWorksheet(dp)
ws.Copy(Before:=wb.Worksheets(1))
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.