10-28-2020
12:22 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
10-28-2020
12:22 PM
Hi WCrihfield
Your code also doesn't work, it's still a bug
Private Sub TestExcel2()
Dim oExcel As Object
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
Dim oWB As Workbook ''Workbook
If oExcel.Workbooks.Count = 0 Then
Set oWB = oExcel.Workbooks.Add()
Else
Set oWB = oExcel.Workbooks.Item(1)
'or
'oWB = oExcel.ActiveWorkbook
End If
Dim oWS As WorkSheet
If oWB.Worksheets.Count = 0 Then
oWS = oWB.Worksheets.Add
Else
oWS = oWB.ActiveSheet
'or
'oWS = oWB.Worksheets..Item(1)
End If
oWS.Cells(1, 1).Value = "Works !"
oWB.SaveAs ("c:\Temp\test.xls") 'Save excel
oExcel.Quit
oWS = Nothing
oWB = Nothing
oExcel = Nothing
End SubAfter command
Set oWB = oExcel.Workbooks.Add()
in watch window I see workbooks.count changed from 0 to 1
and show error and
oWB = Nothing !!
I note that on a PC where the Inventor2021 + excel2007 code works
does not work on PCs where it is Inventor 2021 + excel 2016
Sorry about my English
Thanks