11-07-2023
07:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-07-2023
07:06 AM
Hi @C_Haines_ENG . I added a comma in line 20 excelApp = GetObject(, "Excel.Application") and now the code works fine.
FileDIR = "C:\BOM Calculator\PART_BOM.xlsx"
excelApp = CreateObject("Excel.Application")
excelApp.Visible = True
excelApp.DisplayAlerts = False
excelWorkbook = excelApp.Workbooks.Add
excelApp.Columns.AutoFit
excelWorkbook.SaveAs(FileDIR)
excelApp.Application.Visible = True
'Ask If You Want to Close Excel File
Question = MessageBox.Show("Close Excel File?", "Title", MessageBoxButtons.YesNo)
excelApp = Nothing
If Question = vbYes
Try
excelApp = GetObject(, "Excel.Application")
For Each wb As Object In excelApp.workbooks
MessageBox.Show(wb.fullname)
If UCase(wb.fullname) = UCase(FileDIR)
wb.Save
wb.Close
End If
Next
Catch
Finally
excelApp.Quit
excelApp = Nothing
End Try
Else
End If
Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.