The GetObject method throws error 429, but the task manager shows an Excel.EXE image

When I open Excel (manually), I get a warning that my Personal.xls is already in use by a "different user". This indicates that the Excel process is running. I confirm this in Task Manager - Excel really works.

So, I put together a quick sub to try to close it, and this procedure causes error 429 on Set x = GetObject(, "Excel.Application").

Sub QuitExcel()
Dim x As Object
Set x = GetObject(, "Excel.Application")
x.Quit
End Sub

Question: Why GetObjectdoes the method not work?

Excel appears, as indicated by the task manager, as well as a warning that appears when you open Excel from the taskbar.

Update from comments

- , Personal.xls, . , . , Excel.EXE .

Sub GetExcel()
Dim x As Object
On Error Resume Next
    Set x = GetObject(, "Excel.Application")
    x.Quit
    Exit Sub
If Err Then
    Set x = GetObject("C:\Users\david_zemens\AppData\Roaming\Microsoft\Excel\XLSTART\PERSONAL.xls")
End If
On Error GoTo 0
x.Parent.Visible = True
x.Parent.Quit


End Sub
+4
1

Personal.xls( Personal.xlsb Excel 2007+) Excel VBA. , , Excel, Personal.xls * % appdata%\Microsoft\Excel\XLSTART. Excel - //RUN.

VBA:

Shell "taskkill /f /im Excel.exe"

Run/Command Prompt:

taskkill /f /im Excel.exe

. Excel, , . - , Excel /, .

+1

Source: https://habr.com/ru/post/1542358/


All Articles