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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,969
Office Version
  1. 365
Platform
  1. Windows
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
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,752
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
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
 

Watch MrExcel Video

Forum statistics

Threads
1,130,336
Messages
5,641,565
Members
417,222
Latest member
Broflovski

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
Top