(view source code of iebuttons.vbs as plain text)
' 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 ExplicitWScript.Echo IEButtons( )
Function IEButtons( )
' This function uses Internet Explorer to create a dialog. Dim objIE, sTitle, iErrorNum ' Create an IE objectSet objIE = CreateObject( "InternetExplorer.Application" )
' specify some of the IE window's settingsobjIE.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 screenWith objIE.Document.parentWindow.screen
objIE.Left = (.availWidth - objIE.Width ) \ 2
objIE.Top = (.availheight - objIE.Height) \ 2
End With
' Wait till IE is readyDo While objIE.Busy
WScript.Sleep 200
Loop ' Insert the HTML code to prompt for user inputobjIE.Document.body.innerHTML = "<div align=""center"">" & vbcrlf _
& "<p><input type=""hidden"" id=""OK"" name=""OK"" value=""0"">" _
& "<input type=""submit"" value="" Limited User "" onClick=""VBScript:OK.value=1""></p>" _
& "<input type=""submit"" value="" Standard User "" onClick=""VBScript:OK.value=2""></p>" _
& "<input type=""submit"" value="" Power User "" onClick=""VBScript:OK.value=4""></p>" _
& "<input type=""submit"" value="" Admin User "" onClick=""VBScript:OK.value=8""></p>" _
& "<p><input type=""hidden"" id=""Cancel"" name=""Cancel"" value=""0"">" _
& "<input type=""submit"" id=""CancelButton"" value="" Cancel "" onClick=""VBScript:Cancel.value=-1""></p></div>"
' Hide the scrollbarsobjIE.Document.body.style.overflow = "auto"
' Make the window visibleobjIE.Visible = True
' Set focus on Cancel buttonobjIE.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 reasonOn 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
LoopOn Error Goto 0
objIE.Visible = False
' Read the user input from the dialog windowIEButtons = objIE.Document.all.OK.value
' Close and release the objectobjIE.Quit
Set objIE = Nothing
End Function
page last modified: 2025-10-11; loaded in 0.0079 seconds