markblandford
markblandford

Reputation: 3193

Unhide Excel Application Session

I have an Excel VBA method (I didn't write it) that runs and one of the first things it does is hide the Excel session Application.Visible = False.

However, when the method has finished, it does not unhide the Excel session so it remains open and listed in the Task Manager but is hidden and seemingly unusable.

Does anyone know, without have the VBE open (so one can access the Immediate Window and run Application.Visible = True), how to unhide this Excel session? At the moment, I'm simply having to kill the session using the Task Manager.

This isn't a massive deal but I'm just interested if anyone knows how to resurrect such a session.

Upvotes: 8

Views: 29746

Answers (5)

Thomas
Thomas

Reputation: 48

No need for word macro at all.

Open up another excel workbook.

Hit Ctrl+F11 to go to the VBA editor and there yoy will see the running but hidden excel file on the left. Search the code of the hidden application file for Application.Visible = False and comment it out. Save and restart the file. Alternatively you can get back the application to show without closing if you type Application.Visible = True in the immediate window (Ctrl+G)

Upvotes: 0

Siddharth Rout
Siddharth Rout

Reputation: 149295

Like I said, it's not a big deal but was just interested if anyone knew of shortcut key or anything to bring it back.

There is no shortcut as such that I am aware of but you can do this.

Open MS Word and paste this code in the VBA Editor. Close all open instances of Excel which are visible and then run and this code. This will make a 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 am not deliberately using a loop as the hidden instance can have a workbook which you might like to save?

If you want you can convert the above code to a VB Script document which you can directly run from the desktop.

Unfortunately, I don't have the control to make the changes required.

What do you exactly mean? Is the VBA Password Protected? If no then my suggestion is still the same as earlier

This is a case of poor programming. Even if we give a code to close all hidden Excel instances, that won't help you. Because next time you run that macro, you will face the same problem again. Why not edit the existing code and add Application.Visible = True at the end? Is the VBA password protected? – Siddharth Rout 28 mins ago

Upvotes: 15

John David Barbosa
John David Barbosa

Reputation: 31

A good solution!

Open up Word, assuming you have it, and open the VBA Editor there, then open the Immediate Window (Ctrl+G) and type:

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

and press enter.

Upvotes: 1

Nemet Attila
Nemet Attila

Reputation: 26

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

Upvotes: 0

Vasil
Vasil

Reputation: 1

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

Look for a line like this ActiveWorkbook.Close that might be the reason you cannot unhide the session.

If you can find it, put Application.Visible = True just before it and voila.

Upvotes: 0

Related Questions