Application.Quit doesnt terminate the Process

Gindo70

New Member
Joined
Oct 9, 2017
Messages
6
Hello,
i have following Problem:
I wrote a Macro in Word, that opens an Excel file, changes stuff and saves ist again. When it runs a second time i get "method rows of object _global failed" as Error. (It works fine, if i close Word inbetween the runs).
I suppose it's because the EXCEL:EXE *32 process does not terminate. (i can see it in the Task-Manager)
I appreciate any help.
Code:
    Dim oExcel As Excel.Application
    Dim oWB As Workbook
    Set oExcel = New Excel.Application
    oExcel.Visible = False
    Set oWB = oExcel.Workbooks.Open(spath)
    NextRow = oWB.Worksheets(1).Range("A" & Rows.Count).End(xlUp).Row + 1 ' Error at this row
    'more code
    oWB.Save
    
    oWB.Close
    oExcel.Quit
 
Last edited by a moderator:

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Untested, but try
Code:
Dim oExcel As Excel.Application
Dim oWB As Workbook
Set oExcel = New Excel.Application
oExcel.Visible = False
Set oWB = oExcel.Workbooks.Open(sPath)
With oWB.Worksheets(1)
    NextRow = .Range("A" & .Rows.Count).End(xlUp).Row + 1
End With
'more code
oWB.Save

oWB.Close
oExcel.Quit
 
Upvote 0
Because the red part below was not properly qualified and was therefore creating an implicit reference to an Excel.Application object that you had no control over (which is why the process remained running):

Rich (BB code):
NextRow = oWB.Worksheets(1).Range("A" & Rows.Count).End(xlUp).Row + 1
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,242
Members
452,623
Latest member
russelllowellpercy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top