message box transient -sub by Chip Perason

  • Thread starter Thread starter R.VENKATARAMAN
  • Start date Start date
R

R.VENKATARAMAN

In one of my serches in googles group I found pearson's sub on having a
transient message box

quote
Dim SH As IWshRuntimeLibrary.WshShell
Dim Res As Long
Set SH = New IWshRuntimeLibrary.WshShell
Res = SH.Popup(Text:="Click Me", secondstowait:=5, _
Title:="Hello, World", Type:=vbOKOnly)
unquote

as suggested i have referenced in vbeditor tools references

<windows scripting host object model(ver 1.0)>

and then run the above sub
But I get an error message and the sub stops at the line

<Dim SH As IWshRuntimeLibrary.WshShell>

the error mesage is
<user defined type not defind>

where I am doing the mistake

mine excel 2000
windows 98SE

request help
thanks regards.
 
Looks like you didn't get all of the post.
What you need to do is to set a reference to the
"Windows Script Host Object Model" on the
Tools | References menu in the VBE.

Jim Cone
San Francisco, USA


In one of my serches in googles group I found pearson's sub on having a
transient message box

quote
Dim SH As IWshRuntimeLibrary.WshShell
Dim Res As Long
Set SH = New IWshRuntimeLibrary.WshShell
Res = SH.Popup(Text:="Click Me", secondstowait:=5, _
Title:="Hello, World", Type:=vbOKOnly)
unquote

as suggested i have referenced in vbeditor tools references
<windows scripting host object model(ver 1.0)>
and then run the above sub
But I get an error message and the sub stops at the line
<Dim SH As IWshRuntimeLibrary.WshShell>
the error mesage is
<user defined type not defind>
where I am doing the mistake
mine excel 2000
windows 98SE
request help
thanks regards.
 
Are you sure you have the right OCX referenced?

On my machine (XP, XL2003) it is called (exactly) "Windows Script Host
Object Model".

c:\windows\system32\wshom.ocx

Maybe it doesn't work on 98SE? Sorry I can't be of more help.

Gareth
 
no. in my messsage I have clearly written I have referenced the particular
refernce (see line below "unquote")
 
thanks. there is no other reference . is the problem with windows98 or excel
version excel 2000.
the file wshom.ocx is in forlder c:\windows\system(not in system32).
 
Hi,
you can find information about Popup method on the Object Browser.
(press F2 in the Visual Basic Editor)
the following works on my PC.

Sub Test1()

'Win98SE, Excel 2000
'Reference
' Library IWshRuntimeLibrary
' C:\WINDOWS\SYSTEM\WSHOM.OCX
' Windows Script Host Object Model (Ver 1.0)

Dim SH As IWshRuntimeLibrary.IWshShell_Class
Dim Res As Long
Set SH = New IWshRuntimeLibrary.IWshShell_Class
Res = SH.Popup(bstrText:="Click Me", pvarSecondsToWait:=5, _
pvarTitle:="Hello, World", pvarType:=vbOKOnly)
End Sub

Sub Test2()
Dim Res As Long
Res = CreateObject("WScript.Shell") _
.Popup("Click Me", 5, "Hello, World", 0)
End Sub
 
The routine appears to work for everyone else but, like you, not in my W98 /
XL2K. The msgbox pops up but does not disappear after SecondsToWait, only if
I click out.

I set a ref to "Windows Script Host Object Model" WSHOM.OCX

I get the following intellisense after typing "res = SH.Popup("

Popup(Text as String,[SecondsToWait],[Title],[Type]) As Long

So it looks like it should work, strange it doesn't. If I don't send aType
(button), the only way to close the msgbox is with Ctrl-Alt-Del. My
WSHOM.OCX is version 5.6.0.6626. I think v5.6 is current, not v1.0.

I don't recall ever having updated my WSHOM.OCX. There's one version for W98
/ ME / NT and another for all later versions of Windows. Maybe we have the
wrong version for our OS, possibly from some poor installer. I'll try and
look into it later.

Regards,
Peter T
 
Maybe we have the wrong version for our OS, possibly from some poor
installer.

I installed the latest version WSHOM.OCX 5.6.0.8825 for W98

http://www.microsoft.com/downloads/details.aspx?FamilyID=0A8A18F6-249C-4A72-
BFCF-FC6AF26DC390&displaylang=en&Hash=TLJCWD

No difference, still doesn't work (ie clear the popup after SecondsToWait)

Peter T

The routine appears to work for everyone else but, like you, not in my W98 /
XL2K. The msgbox pops up but does not disappear after SecondsToWait, only if
I click out.

I set a ref to "Windows Script Host Object Model" WSHOM.OCX

I get the following intellisense after typing "res = SH.Popup("

Popup(Text as String,[SecondsToWait],[Title],[Type]) As Long

So it looks like it should work, strange it doesn't. If I don't send aType
(button), the only way to close the msgbox is with Ctrl-Alt-Del. My
WSHOM.OCX is version 5.6.0.6626. I think v5.6 is current, not v1.0.

I don't recall ever having updated my WSHOM.OCX. There's one version for W98
/ ME / NT and another for all later versions of Windows. Maybe we have the
wrong version for our OS, possibly from some poor installer. I'll try and
look into it later.

Regards,
Peter T

R.VENKATARAMAN said:
In one of my serches in googles group I found pearson's sub on having a
transient message box

quote
Dim SH As IWshRuntimeLibrary.WshShell
Dim Res As Long
Set SH = New IWshRuntimeLibrary.WshShell
Res = SH.Popup(Text:="Click Me", secondstowait:=5, _
Title:="Hello, World", Type:=vbOKOnly)
unquote

as suggested i have referenced in vbeditor tools references

<windows scripting host object model(ver 1.0)>

and then run the above sub
But I get an error message and the sub stops at the line

<Dim SH As IWshRuntimeLibrary.WshShell>

the error mesage is
<user defined type not defind>

where I am doing the mistake

mine excel 2000
windows 98SE

request help
thanks regards.
 
thanks for all those who tried to help


===================
Peter T said:
Maybe we have the wrong version for our OS, possibly from some poor
installer.

I installed the latest version WSHOM.OCX 5.6.0.8825 for W98

http://www.microsoft.com/downloads/details.aspx?FamilyID=0A8A18F6-249C-4A72-
BFCF-FC6AF26DC390&displaylang=en&Hash=TLJCWD

No difference, still doesn't work (ie clear the popup after SecondsToWait)

Peter T

The routine appears to work for everyone else but, like you, not in my
W98
/
XL2K. The msgbox pops up but does not disappear after SecondsToWait,
only
if
I click out.

I set a ref to "Windows Script Host Object Model" WSHOM.OCX

I get the following intellisense after typing "res = SH.Popup("

Popup(Text as String,[SecondsToWait],[Title],[Type]) As Long

So it looks like it should work, strange it doesn't. If I don't send aType
(button), the only way to close the msgbox is with Ctrl-Alt-Del. My
WSHOM.OCX is version 5.6.0.6626. I think v5.6 is current, not v1.0.

I don't recall ever having updated my WSHOM.OCX. There's one version for W98
/ ME / NT and another for all later versions of Windows. Maybe we have the
wrong version for our OS, possibly from some poor installer. I'll try and
look into it later.

Regards,
Peter T

R.VENKATARAMAN said:
In one of my serches in googles group I found pearson's sub on having a
transient message box

quote
Dim SH As IWshRuntimeLibrary.WshShell
Dim Res As Long
Set SH = New IWshRuntimeLibrary.WshShell
Res = SH.Popup(Text:="Click Me", secondstowait:=5, _
Title:="Hello, World", Type:=vbOKOnly)
unquote

as suggested i have referenced in vbeditor tools references

<windows scripting host object model(ver 1.0)>

and then run the above sub
But I get an error message and the sub stops at the line

<Dim SH As IWshRuntimeLibrary.WshShell>

the error mesage is
<user defined type not defind>

where I am doing the mistake

mine excel 2000
windows 98SE

request help
thanks regards.
 
I should have made clear there's quite a difference in the way things don't
work for us. You said -
"
But I get an error message and the sub stops at the line
<Dim SH As IWshRuntimeLibrary.WshShell>
"
Unlike you I don't get an error, but it just doesn't work as expected.

Regards,
Peter T

R.VENKATARAMAN said:
thanks for all those who tried to help


===================
Peter T said:
I installed the latest version WSHOM.OCX 5.6.0.8825 for W98
http://www.microsoft.com/downloads/details.aspx?FamilyID=0A8A18F6-249C-4A72-
BFCF-FC6AF26DC390&displaylang=en&Hash=TLJCWD

No difference, still doesn't work (ie clear the popup after SecondsToWait)

Peter T

The routine appears to work for everyone else but, like you, not in my
W98
/
XL2K. The msgbox pops up but does not disappear after SecondsToWait,
only
if
I click out.

I set a ref to "Windows Script Host Object Model" WSHOM.OCX

I get the following intellisense after typing "res = SH.Popup("

Popup(Text as String,[SecondsToWait],[Title],[Type]) As Long

So it looks like it should work, strange it doesn't. If I don't send aType
(button), the only way to close the msgbox is with Ctrl-Alt-Del. My
WSHOM.OCX is version 5.6.0.6626. I think v5.6 is current, not v1.0.

I don't recall ever having updated my WSHOM.OCX. There's one version
for
W98
/ ME / NT and another for all later versions of Windows. Maybe we have the
wrong version for our OS, possibly from some poor installer. I'll try and
look into it later.

Regards,
Peter T

In one of my serches in googles group I found pearson's sub on
having
 
You could also use late binding and drop the reference:

Dim SH As Object
Dim Res As Long
Set SH = CreateObject("wscript.shell")
Res = SH.Popup(Text:="Click Me", secondstowait:=5, _
Title:="Hello, World", Type:=vbOKOnly)
 
apologise for asking a dumb question. what is late binding. what should I
do.
I removed the tick from the reference list.
still sub stops at

Res=etc. etc..

error
<named argument not found>
================================
 
Hi Peter,
Unlike you I don't get an error, but it just doesn't work as expected

My experience replicates yours, albeit with a xl2k/winXp configuration: the
message box appears (without error) but requires manual dismissal.
 
Hey Norman,

I thought that originally - but then (I don't know why) I sulked and
refused to click it away and it disappeared of its own volition after
about 40". Out of curiosity, maybe it's the same for you?

Indeed, I decided to change the SecondsToWait parameter and the results
were as follows:

Sec nn:ss
1 - 00:03
2 - 02:08
3 - 00:27
3 - 00:07
4 - 00:27
5 - 00:19

Clearly inconsistent - makes this somewhat unusable.

Thanks,
Gareth
 
Hi Gareth,
Out of curiosity, maybe it's the same for you?

I'm afraid not.

My attention span collapsed after 90 secs and I manually closed.

Perhaps, however, I do not have your prodigious sulking ability!
 
Hi Norman,

I was anticipating coming back to this thread needing to start my reply
with -Doh...! So I'm rather glad you report similar.

Gareth's observations are interesting, but like you I don't have enough
"sulking ability" to see for myself!

No doubt there's some simple explanation, but whatever it is in the light of
our experiences it suggests the method cannot be distributed reliably, a
shame.

Dave - re your suggestion in another part of this thread:
Before posting my first reply I had tried Late Binding but got the same non
result, ie no error but the popup msgbox wouldn't close without me clicking.
First time forgot to include a button, eventually had to Ctrl-Alt-Del.

Regards,
Peter T
 
Hey Peter - Just in case you're interested, I just tried with late
binding. It works as previously for me i.e. goes away eventually but
with varying durations (albeit seemingly a little closer to the seconds
value passed).
 
Hi Norman,

So we're not alone, I couldn't follow the link Tom referred to but his
comments are enough. Adds weight to this not being a reliable method.

Not sure if relevant but I notice in the OP's quote of the routine and in
okaizawa's they both mention (ver 1.0) appended to the reference
description. No version info appears in my description and if Gareth quoted
in full in his first post likewise for him.

I got the detailed version info I mentioned previously by rt-clicking
WSHOM.OCX and checking properties.

Gareth - following your latest I tried to be a little bit sulky and tried
Early & Late binding again. Left for quite a while but the message would not
disappear without, as Norman said, manual dismissal. Wouldn't even work with
verbal dismissal of the ancient kind, but it made me feel better.

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top