Someone in another forum asked if there was a way to make MsgBox "timeout." There isn't. Nor is there a way to "timeout" InputBox or User Defined Forms. They're all Modal, and halt execution until someone dismisses the dialog.

So, I came-up with the following code.

We open Internet Explorer using a little-known trick using a tweaked "About:" URI that actually creates a partial form containing an Input "Text" box. We loop for up-to 10 seconds. If the outside user has changed the content of the textbox, we'll loop for up-to 3 more seconds. We'll keep adding 3 seconds as long as the user continues to make changes to the content.

When the user is finished, we get the contents of the textbox, and continue processing.

You could have more than one textbox, and/or checkboxes, radio buttons, whatever floats your boat.

I didn't check to see if the user actually added anything in this code sample. If you checked, and they didn't, then you could "default" to a specific value.


<font class="small">Code:</font><hr /><pre>
Sub Main()

'''''''''''''''''''''''''''''''''''''''''''''''''' '''
''' Note:
''' You MUST INCLUDE the following two VB References:
''' Microsoft Internet Controls
''' Microsoft HTML Object Library
''' In TestPartner, with your script open, chuse:
''' Tools References
'''''''''''''''''''''''''''''''''''''''''''''''''' '''

Dim sValue As String
Dim sOldValue As String
Dim iSleep As Integer
Dim iSleepCont As Integer
iSleep = 10 ' 10 seconds to start
iSleepCont = 3 ' 3 secs continuation

Dim oIe As New InternetExplorer
Dim oIeDoc As MSHTML.HTMLDocument
Dim colTxtEdit As IHTMLElementCollection

' Make all the clutter-stuff (buttons, location
' bar, status bar, menus, etc) disappear in IE:
oIe.FullScreen = True

oIe.Height = 200
oIe.Width = 350

oIe.Visible = True

Dim lngHwnd As Long

' Note: &lt;HTML&gt;&lt;/HTML&gt; tags generated automatically!!!
oIe.Navigate "About:&lt;body&gt;Type Here: " &amp; _
"&lt;input type=""text"" name=""txtCmt"" /&gt;&lt;/body&gt;"

While oIe.ReadyState &lt;&gt; READYSTATE_COMPLETE

lngHwnd = oIe.hWnd

Set oIeDoc = oIe.Document
oIeDoc.Title = "Hello, world!"

Set colTxtEdit = oIeDoc.getElementsByTagName("input")

' get current value of input box
sOldValue = colTxtEdit.Item("txtCmt").Value

While iSleep &gt; 0
Sleep 1 ' sleep one second
iSleep = iSleep - 1

' if something has changed, then reset the "timer"
If Len(colTxtEdit.Item("txtCmt").Value) &lt;&gt; Len(sOldValue) _
iSleep = iSleepCont ' reset timer

' update the current value
sOldValue = colTxtEdit.Item("txtCmt").Value
End If

' get final value
sValue = colTxtEdit.Item("txtCmt").Value

' close our IE window
Window("hWnd=" &amp; lngHwnd).Attach

' continue processing...
MsgBox sValue

' clean-up our house...
Set oIe = Nothing
Set oIeDoc = Nothing
Set colTxtEdit = Nothing

End Sub
</pre><hr />