' Creates a menu of buttons in IE ' you click a button and it returns a value ' Returns 0 if user clicks Cancel of the red X (or alt-F4) to close IE window instead of making a selection Option Explicit WScript.Echo IEButtons( ) Function IEButtons( ) ' This function uses Internet Explorer to create a dialog. Dim objIE, sTitle, iErrorNum ' Create an IE object Set objIE = CreateObject( "InternetExplorer.Application" ) ' specify some of the IE window's settings objIE.Navigate "about:blank" sTitle="Make your choice " & String( 80, "." ) 'Note: the String( 80,".") is to push "Internet Explorer" string off the window objIE.Document.title = sTitle objIE.MenuBar = False objIE.ToolBar = False objIE.AddressBar = false objIE.Resizable = False objIE.StatusBar = False objIE.Width = 250 objIE.Height = 280 ' Center the dialog window on the screen With objIE.Document.parentWindow.screen objIE.Left = (.availWidth - objIE.Width ) \ 2 objIE.Top = (.availheight - objIE.Height) \ 2 End With ' Wait till IE is ready Do While objIE.Busy WScript.Sleep 200 Loop ' Insert the HTML code to prompt for user input objIE.Document.body.innerHTML = "
" & vbcrlf _ & "

" _ & "

" _ & "

" _ & "

" _ & "

" _ & "

" _ & "

" ' Hide the scrollbars objIE.Document.body.style.overflow = "auto" ' Make the window visible objIE.Visible = True ' Set focus on Cancel button objIE.Document.all.CancelButton.focus 'CAVEAT: If user click red X to close IE window instead of click cancel, an error will occur. ' Error trapping Is Not doable For some reason On Error Resume Next Do While objIE.Document.all.OK.value = 0 and objIE.Document.all.Cancel.value = 0 WScript.Sleep 200 iErrorNum = Err.Number If iErrorNum <> 0 Then 'user clicked red X (or alt-F4) to close IE window IEButtons = 0 objIE.Quit Set objIE = Nothing Exit Function End if Loop On Error Goto 0 objIE.Visible = False ' Read the user input from the dialog window IEButtons = objIE.Document.all.OK.value ' Close and release the object objIE.Quit Set objIE = Nothing End Function