close msgbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I am importing to excel data from another application (Bloomberg) then
creating a graph from it.
I have noticed that the data is not imported properly (only the firlt line
is displyed) unless I call a message box between the import of data and the
graph plotting of data ( I guess it needs some kind of break in order to copy
the data).
My problem is that I do not want this message box and trying to find a way
to closed automatically, I have tried sendimg {enter} via send key, I have
tried to just put a Application.Wait Now + TimeValue("00:00:05") intead of
calling a msgbox. But all that dis not work either.
Any idea
Thanks
Dan
 
Here is some code for a timed message box... Make sure to add the reference
via Tools -> References.

'requires reference to "Windows Script Host Object Model"
Public Sub MessageTest()
Dim SH As IWshRuntimeLibrary.WshShell
Dim Res As Long

Set SH = New IWshRuntimeLibrary.WshShell
Res = SH.Popup(Text:="Click Me", secondstowait:=2, _
Title:="Hello, World", Type:=vbOKOnly)

End Sub
 
Thank you Jim,
I have put the reference but it is still waiting for the user to click OK
and does not close on it's own.
 
Set the SecondsToWait at 1 second. Sometimes it takes a bit longer than the
preset time to close.
 
Unfortunately the wsh method to close a msgbox is notoriously unreliable.
Referring to your OP, if I understand you only need to temporarily display
the msgbox to overcome some other problem and not as feedback to user.
Actually I don't understand that at all but if that's really all you want to
do try this -

Application.SendKeys "{ESC}"
MsgBox "Gone so soon"

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