Here's some actual code (This code runs without a hitch on my development machine, after building, packaging and installing on a test machine, windows xp pro, I get the failure error that I mentioned above)
Public Class CSendToExcel
Private ds As DataSet
Sub New(ByRef m_Ds As DataSet)
ds = m_Ds
End Sub
Sub Dispose()
GC.Collect()
End Sub
Public Sub SendDataToExcel()
MsgBox("success .1")
Dim xlapp As Excel.Application
MsgBox("success .2")
Dim xlbook As Excel.Workbook
MsgBox("success .3")
Dim xlsheet As Excel.Worksheet
MsgBox("success .5")
Try
xlapp = New Excel.Application
MsgBox("success .6")
xlbook = xlapp.Workbooks.Add ' THIS LINE FAILS ON THE XP MACHINE BUT THE WHOLE CLASS RUNS PERFECT ON MY DEVELOPMENT MACHINE
MsgBox("success .7")
xlsheet = xlapp.Sheets(1)
MsgBox("success 1")
With xlsheet
.PageSetup.Orientation = Excel.XlPageOrientation.xlLandscape
.PageSetup.LeftMargin = 0.23
.PageSetup.LeftMargin = 0.5
.Range("A1", "J35").HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft
.Name = "Labor Model"
.Cells(1, 1).Value = "Labor Model"
.Cells(1, 1).Font.Size = 14
.Cells(3, 1).Value = "Department"
.Cells(3, 3).Value = ds.Tables("Header").Rows(0).Item(1)
.Cells(4, 1).Value = "Section"
.Cells(4, 3).Value = ds.Tables("Header").Rows(0).Item(2)
.Cells(5, 1).value = "Shift"
.Cells(5, 3).Value = ds.Tables("Header").Rows(0).Item(3)
.Cells(6, 1).value = "Regular Hours"
.Cells(6, 3).Value = ds.Tables("Header").Rows(0).Item(4)
.Cells(7, 1).value = "OT Hours"
.Cells(7, 3).Value = ds.Tables("Header").Rows(0).Item(5)
.Cells(8, 1).Value = "Total Est Vol"
.Cells(8, 3).Value = Format(ds.Tables("Header").Rows(0).Item(8), "###,###,###.##")
.Cells(9, 1).value = "Total Est Salv"
.Cells(9, 3).Value = Format(ds.Tables("Header").Rows(0).Item(9), "$###,###,###.##")
.Cells(10, 1).value = "Total Exp Salv"
.Cells(10, 3).Value = Format(ds.Tables("Header").Rows(0).Item(10), "$###,###,###.##")
.Cells(11, 1).value = "Total Exp Units"
.Cells(11, 3).Value = Format(ds.Tables("Header").Rows(0).Item(11), "###,###,###.##")
.Range("A1", "A35").ColumnWidth = 12.71
.Range("A1", "J35").ColumnWidth = 12.0
.Range("C1", "C35").ColumnWidth = 14.0
.Range("A3", "J35").Font.Size = 10
End With
MsgBox("Success 2")
xlsheet.PrintOut()
xlapp.Quit()
Catch ex As Exception
MsgBox(Err.Description)
Finally
xlsheet = Nothing
xlapp = Nothing
End Try
End Sub
End Class