Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

scripting with the internet explorer object

Status
Not open for further replies.

bn2hunt

MIS
May 15, 2003
203
US
I found this code in tek-tips and have been trying to modify it to fit my needs. I want to create a popup box that will allow the user running the script to click on a button and then set a variable for the rest of the script to use. I can get the script below to create the buttons but how do I pass the variable back into the rest of the script. Ideally if I can get this to work it would all run inside of a subroutine and then pass the inputed information back to the main script.

Thanks for any input

Dan

Code:
Set objExplorer = wscript.CreateObject("InternetExplorer.Application","IE_")
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width = 800
objExplorer.Height = 570
objExplorer.Left = 0
objExplorer.Top = 0
objExplorer.Visible = 1
variable = "0"

Set objDocument = objExplorer.Document
objDocument.Open

objDocument.Writeln "<html><head><title>CCN Announcement</title>"


objDocument.Writeln "<script language=VBScript>"
objDocument.Writeln "Sub cmdFull_onClick()"
objDocument.writeln "msgbox ""You have chosen to Do the Full Backup"""    'inserted for visual testing
objDocument.writeln "variable = 1"
objDocument.writeln "msgbox variable"
objDocument.writeln "WScript.Quit"
objDocument.writeln "End Sub"

objDocument.Writeln "Sub cmdPartial_onClick()"
objDocument.writeln "msgbox ""You have chosen to Do the Partial Backup"""    'inserted for visual testing
objDocument.writeln "variable = 2"
objDocument.writeln "msgbox variable"
objDocument.writeln "WScript.Quit"
objDocument.writeln "End Sub"

objDocument.writeln "</script>"


objDocument.writeln "</head>"
objDocument.Writeln "<body bgcolor=#5959ab>"
objDocument.Writeln "<h2>Communication Details</h2>"
objDocument.Writeln "<Br>"
objDocument.Writeln "<Br>"
objDocument.Writeln "<input align=centre id=cmdFull type=Button name=cmdFull value=""Full Backup"">"
objDocument.Writeln "<input align=centre id=cmdPartial type=Button name=cmdPartial value=""Partial Backup"">"
objDocument.Writeln "</body></html>"

'this is the single _most_ crucial step to make the script successful
objDocument.close



do while true : wscript.sleep 100 : loop

Sub IE_onQuit()
        msgbox variable
'    msgbox "onQuit event fired."
   Wscript.Quit
End Sub
 
If I follow what you're asking,

Code:
MyVariable =  Inputbox("Please enter variable")

If MyVariable = <whatever> Then
   ...
End If

-If it ain't broke, break it and make it better.
 
Oh wait, I didn't follow your question.

-If it ain't broke, break it and make it better.
 
objDocument.writeln "variable = inputbox(""enter value:"",, variable)"

As for passing back to 'main script', you could Dim variable at the global level.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top