Excel application still running in background after Application.Quit

Excel application still running in background after Application.Quit

nicolamora
Contributor Contributor
766 Views
2 Replies
Message 1 of 3

Excel application still running in background after Application.Quit

nicolamora
Contributor
Contributor

I'm formatting an Excel workbook from an Inventor macro, but after a selection range of cell the cycle "With, End With" doesn't allow Excel to close properly and remain open in background preventing the code to continue. 

Any help is appreciate

 

 

Dim XL As Excel.Application
Dim xlWB As Excel.Workbook
Dim xlWS As Excel.WorkSheet

Set XL = CreateObject("Excel.Application")
Set xlWB = XL.Workbooks.Open("c:\temp\" & name & ".xlsx")
Set xlWS = xlWB.Worksheets(1)
XL.Visible = False 'True

xlWS.Activate

xlWS.Rows("1:1").HorizontalAlignment = XlHAlign.xlHAlignCenter
xlWS.Rows("1:1").Font.Bold = True

xlWS.Columns("A:A").ColumnWidth = 6
xlWS.Columns("B:B").ColumnWidth = 22
xlWS.Columns("C:C").ColumnWidth = 18
xlWS.Columns("D:D").ColumnWidth = 45
xlWS.Columns("E:E").ColumnWidth = 6

 

xlWS.Range("A1:E1").Select

          With Selection.Interior
                  .Pattern = xlSolid
                  .PatternColorIndex = xlAutomatic
                  .Color = 65535
                   .TintAndShade = 0
                   .PatternTintAndShade = 0
          End With

 

xlWB.Save
xlWB.Close True
XL.Application.Quit

Set xlWS = Nothing
Set xlWB = Nothing
Set XL = Nothing

 

Exit Sub
End Sub

0 Likes
767 Views
2 Replies
Replies (2)
Message 2 of 3

bradeneuropeArthur
Mentor
Mentor

you need to kill the process.

I was having the same issue here.

since I killed the related process it works good.

 

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 3

YuhanZhang
Autodesk
Autodesk

You can try to use the Range instead of the Selection:

 

Dim oRange As Range
Set oRange = xlWS.Range("A1:E1")

          With oRange.Interior
                  .Pattern = xlSolid
                  .PatternColorIndex = xlAutomatic
                  .Color = 65535
                   .TintAndShade = 0
                   .PatternTintAndShade = 0
          End With

Hope this helps.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes