Show Excel Application Session

I have an Excel VBA method (I did not write it) that is executing, and one of the first things it does is to hide the Excel Application.Visible = False session.

However, when the method is finished, it does not display the Excel session, therefore it remains open and is displayed in the task manager, but it is hidden and seemingly inoperative.

Does anyone know without opening VBE (so that you can open the Immediate window and run Application.Visible = True ) how to display this Excel session? For now, I just need to kill the session using the task manager.

This is not a big deal, but I'm just wondering if anyone knows how to resurrect such a session.

+6
source share
4 answers

As I said, this is not very important, but it was just interesting if anyone knew about a shortcut key or something else to get it back.

There is no shortcut, so I know, but you can do it.

Open MS Word and paste this code into the VBA editor. Close all open Excel instances that are visible, and then this code is run. This will make the hidden instance visible. Manually close the instance and repeat the process if there are more instances.

 Option Explicit Sub Sample() Dim oXLApp As Object '~~> Get an existing instance of an EXCEL application object On Error Resume Next Set oXLApp = GetObject(, "Excel.Application") On Error GoTo 0 oXLApp.Visible = True Set oXLApp = Nothing End Sub 

I'm not intentionally using a loop, since a hidden instance might have a book that you could save?

If you want, you can convert the above code into a VB Script document that you can run right from the desktop.

Unfortunately, I do not have a control to make the necessary changes.

What do you have in mind? Is the VBA password protected? If not, then my suggestion still matches the previous one

This is bad programming. Even if we give the code to close all the hidden instances of Excel that will not help you. Because the next time you run this macro, you will encounter the same problem again. Why not modify the existing code and add Application.Visible = True at the end? Is it Password Protected by VBA? - Siddharth Rout 28 minutes ago

+9
source

I had a similar problem and it was solved with reordering a line of code.

Locate a line such as ActiveWorkbook.Close , which may be the reason that you cannot display the session.

If you can find it, put Application.Visible = True directly in front of it and the veil.

0
source

as code:

 sub runthis() dim xl as object set xl = new excel.application 'create session xl.workbooks.open filename:= "«yourpath»" 'open wb in the new session xl.visible=true 'this is what you need, show it up! 'rest of the code end sub 
0
source

Good decision !

Open Word, assuming you have one, and open the VBA editor there, then open the Immediate window (Ctrl + G) and type:

Getobject(, "Excel.Application").Visible = true

and press enter.

0
source

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


All Articles