Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 737
markblandford Avatar asked Apr 24 '12 08:04

markblandford


2 Answers

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

like image 104
Siddharth Rout Avatar answered Sep 21 '22 12:09

Siddharth Rout


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.

like image 28
John David Barbosa Avatar answered Sep 21 '22 12:09

John David Barbosa