Unhide Excel Application Session

markblandford picture markblandford · Apr 24, 2012 · Viewed 27.1k times · Source

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.

Answer

Siddharth Rout picture Siddharth Rout · Apr 24, 2012

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