View Single Post
  #28   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default message box transient -sub by Chip Perason

Not a problem.

Gareth wrote:

Hi Dave,

I didn't mean to give the impression you were suggesting late binding
would fix the box not dismissing itself. Rather, the OP's problem was
that he couldn't get it to even compile, on his 98SE machine, past the
wshshell declaration. As a fix for that, it seemed like a good
suggestion. Sorry if it wasn't clear.

Best regards,
Gareth

Dave Peterson wrote:
Just to add...

I like to use early binding while developing the project. You get all those
intellisense and autocomplete features in the VBE.

But when I'm ready to release it to others, I'll get rid of the references,
declare any constants I used and fix my DIMs to be more generic (As Object).

This means I don't have to worry about version differences--I use version 12 and
someone else uses version 11, my program might break, because of missing
references.

But early/late binding wasn't ever going to fix the problem that the dialog
doesn't dismiss itself. (When I wrote my message, I still thought it was a "how
do I create a reference" problem.)

Gareth wrote:

In a nutshell, late binding is not declaring your objects at design
time, rather you let them be resolved at runtime. It's therefore written
in the code and so whether or not the OCX is referenced in the VBA
project is not important: if you use late binding - it's irrelevant.
(That's not very clear is it!)

Normally early binding is better and faster, as in your original post:

Dim SH As IWshRuntimeLibrary.WshShell
Set SH = New IWshRuntimeLibrary.WshShell

rather than late binding (from Dave Peterson's email)

Dim SH As Object
Set SH = CreateObject("wscript.shell")

But occasionally late binding can be useful - for example here Dave was
hoping it might fix your problem. (Which appears to be insolvable.)

Take a look at CreateObject Function in VBA Help for more info on late
and early binding.

With respect to your OP - I think the consensus is to go with userforms!

HTH

R.VENKATARAMAN wrote:

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
================================
Dave Peterson wrote in message
...


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)



"R.VENKATARAMAN" wrote:


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.

--

Dave Peterson





--

Dave Peterson