ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Runnig Excel without visible application (https://www.excelbanter.com/excel-programming/326196-re-runnig-excel-without-visible-application.html)

[email protected]

Runnig Excel without visible application
 
This was just the thing i've been looking for... but it dosn't work :(
I get a message box that pops up and tells me "Excel Running" .. and
then nothing happens.

I tried moving the "objXL.Visible = true" statement inside the first
If-Else, and that didn't work eaither. <grumble i have a crashed
version of excel sitting in my background somewhere that i need to get
to.

Jon Peltier wrote:
But you can get at that invisible Excel instance in a couple ways.
Ctrl-Alt-Del will give you the list of running apps, but you can only

kill it
from here. The other way was posted by Rob Bruce some time back.

Put this
code into a text file:

' === Begin script ===============
' from Rob Bruce
Dim objXL, strMessage
On Error Resume Next
Set objXL = GetObject(, "Excel.Application")
If Not TypeName(objXL) = "Empty" Then
strMessage = "Excel Running."
Else
strMessage = "Excel Not Running."
End If
MsgBox strMessage, vbInformation, "Excel Status"
if strMessage = "Excel Running." then objXL.Visible = true
' === End script ===============

Save it with a name like "XLcheck.vbs". If you have a hidden Excel

instance,
running this script will bring it up front. If there is no such

hidden
instance, it tells you that, too.

- Jon



Fredrik Wahlgren

Runnig Excel without visible application
 

wrote in message
oups.com...
This was just the thing i've been looking for... but it dosn't work :(
I get a message box that pops up and tells me "Excel Running" .. and
then nothing happens.

I tried moving the "objXL.Visible = true" statement inside the first
If-Else, and that didn't work eaither. <grumble i have a crashed
version of excel sitting in my background somewhere that i need to get
to.

Jon Peltier wrote:
But you can get at that invisible Excel instance in a couple ways.
Ctrl-Alt-Del will give you the list of running apps, but you can only

kill it
from here. The other way was posted by Rob Bruce some time back.

Put this
code into a text file:

' === Begin script ===============
' from Rob Bruce
Dim objXL, strMessage
On Error Resume Next
Set objXL = GetObject(, "Excel.Application")
If Not TypeName(objXL) = "Empty" Then
strMessage = "Excel Running."
Else
strMessage = "Excel Not Running."
End If
MsgBox strMessage, vbInformation, "Excel Status"
if strMessage = "Excel Running." then objXL.Visible = true
' === End script ===============

Save it with a name like "XLcheck.vbs". If you have a hidden Excel

instance,
running this script will bring it up front. If there is no such

hidden
instance, it tells you that, too.

- Jon



I don't think the code will work. The problem is that not all versions of
Excel register themselves in the Running Object Table. If a running
application isn't registered there, GetObject will return NULL. The Soution
to this problem is to get a handle to the main Excel window, called "XLMAIN"
and send the message WM_USER + 18 to it. You can find more information here
http://support.microsoft.com/default...b;EN-US;138723

I also think that the line
If Not TypeName(objXL) = "Empty" Then
should be changed to
If Not objXL is Nothing Then

This is easier to understand.

/Fredrik



Bob Phillips[_6_]

Runnig Excel without visible application
 
You did put it in a vbs file, not in VBA didn't you?

--

HTH

RP
(remove nothere from the email address if mailing direct)


wrote in message
oups.com...
This was just the thing i've been looking for... but it dosn't work :(
I get a message box that pops up and tells me "Excel Running" .. and
then nothing happens.

I tried moving the "objXL.Visible = true" statement inside the first
If-Else, and that didn't work eaither. <grumble i have a crashed
version of excel sitting in my background somewhere that i need to get
to.

Jon Peltier wrote:
But you can get at that invisible Excel instance in a couple ways.
Ctrl-Alt-Del will give you the list of running apps, but you can only

kill it
from here. The other way was posted by Rob Bruce some time back.

Put this
code into a text file:

' === Begin script ===============
' from Rob Bruce
Dim objXL, strMessage
On Error Resume Next
Set objXL = GetObject(, "Excel.Application")
If Not TypeName(objXL) = "Empty" Then
strMessage = "Excel Running."
Else
strMessage = "Excel Not Running."
End If
MsgBox strMessage, vbInformation, "Excel Status"
if strMessage = "Excel Running." then objXL.Visible = true
' === End script ===============

Save it with a name like "XLcheck.vbs". If you have a hidden Excel

instance,
running this script will bring it up front. If there is no such

hidden
instance, it tells you that, too.

- Jon






All times are GMT +1. The time now is 10:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com