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

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
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,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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