|
From: Claude Lachapelle on 21 Jul 2008 11:44 Since with VBScript we are limited to input one field at a time using the inputbox function, I'm trying to write down something that will open an IE form where I will get multiple extended user's information: - employeeNumber - preferredLanguage - division I found some samples, but I'm always getting a lot of errors trying to make them works, actually my VBScript looks like this (initially get from a MVP): Function ExtendedInfo() set oSH = CreateObject("Wscript.Shell") set oIE = CreateObject("InternetExplorer.Application") With oIE .RegisterAsDropTarget = False .FullScreen = True .width = 400 : .height = 200 .Navigate "about:blank" Do Until .ReadyState = 4 : WScript.Sleep 100 : Loop .document.open .document.write _ "<html><head><" & "script>bboxwait=true;</" _ & "script><title>User's Extended Informations</title></head>"_ & "<body bgColor=Silver scroll=no language=vbs" _ & " onkeypress='if window.event.keycode=13 Then" _ & " bboxwait=false'><center>" _ & "<b> Enter user's extended informations<b> <p>" _ & "<table><tr><td> <b>Employee #:</b></td><td>" _ & "<input type=text id=emp value='" & strEmpNumber & "'>" _ & "<button onclick='bboxwait=false;'> Ok </button>" _ & "<button onclick='bboxwait=cancel;'> Cancel </button>" _ & "</center></body></html>" .document.close Do Until .ReadyState = 4 : WScript.Sleep 100 : Loop With .document oIE.left = .parentWindow.screen.width \ 2 - 200 oIE.top = .parentWindow.screen.height\ 2 - 100 .body.style.borderStyle = "outset" .body.style.borderWidth = "3px" .all.user.focus .all.user.select ExtendedInfo = Array("CANCELLED") Do While .parentWindow.bBoxWait oSH.Appactivate "User's Extended Informations" oIE.Visible = True if Err Then Exit Function WScript.Sleep 100 If .parentWindow.bBoxWait = "cancel" Then oIE.Visible = False MsgBox(.parentWindow.bBoxWait) Exit Do End If Loop oIE.Visible = False ExtendedInfo = Split(.all.user.value & "|" & .all.pass.value, "|") End With ' document End With ' IE end function I just modified the function name and where the form is written (for Employee #), and I'm always getting the following error message: Object doesn't support this property or method: 'all.user' and the referred line is .all.user.focus What's wrong with my VBScript??? Thanks. Claude Lachapelle Systems Administrator, MCSE
From: Claude Lachapelle on 21 Jul 2008 14:19 I finally got it to work, but when using a different method: strUserInput = GetUserInput() Function GetUserInput() Dim objIE ' Create an IE object Set objIE = CreateObject( "InternetExplorer.Application" ) ' specify some of the IE window's settings objIE.Navigate "about:blank" objIE.Document.Title = "User's extended informations" objIE.ToolBar = False objIE.Resizable = False objIE.StatusBar = False objIE.Width = 320 objIE.Height = 180 ' 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 = "<DIV align=""center""><P>Employee number:</P>" & vbCrLf _ & "<P><INPUT TYPE=""text"" SIZE=""20"" " _ & "ID=""UserInput""></P>" & vbCrLf _ & "<P><INPUT TYPE=""hidden"" ID=""OK"" " _ & "NAME=""OK"" VALUE=""0"">" _ & "<INPUT TYPE=""submit"" VALUE="" OK "" " _ & "OnClick=""VBScript:OK.Value=1""></P></DIV>" ' Make the window visible objIE.Visible = True ' Wait till the OK button has been clicked Do While objIE.Document.All.OK.Value = 0 WScript.Sleep 200 Loop ' Read the user input from the dialog window GetUserInput = objIE.Document.All.UserInput.Value ' Close and release the object objIE.Quit Set objIE = Nothing End Function But now, I need to insert 2 more fields, how I should proceed? "Claude Lachapelle" wrote: > Since with VBScript we are limited to input one field at a time using the > inputbox function, I'm trying to write down something that will open an IE > form where I will get multiple extended user's information: > > - employeeNumber > - preferredLanguage > - division > > I found some samples, but I'm always getting a lot of errors trying to make > them works, actually my VBScript looks like this (initially get from a MVP): > > Function ExtendedInfo() > > set oSH = CreateObject("Wscript.Shell") > set oIE = CreateObject("InternetExplorer.Application") > > With oIE > > .RegisterAsDropTarget = False > .FullScreen = True > .width = 400 : .height = 200 > .Navigate "about:blank" > > Do Until .ReadyState = 4 : WScript.Sleep 100 : Loop > > .document.open > .document.write _ > "<html><head><" & "script>bboxwait=true;</" _ > & "script><title>User's Extended Informations</title></head>"_ > & "<body bgColor=Silver scroll=no language=vbs" _ > & " onkeypress='if window.event.keycode=13 Then" _ > & " bboxwait=false'><center>" _ > & "<b> Enter user's extended informations<b> <p>" _ > & "<table><tr><td> <b>Employee #:</b></td><td>" _ > & "<input type=text id=emp value='" & strEmpNumber & "'>" _ > & "<button onclick='bboxwait=false;'> Ok </button>" _ > & "<button onclick='bboxwait=cancel;'> Cancel </button>" _ > & "</center></body></html>" > .document.close > > Do Until .ReadyState = 4 : WScript.Sleep 100 : Loop > > With .document > oIE.left = .parentWindow.screen.width \ 2 - 200 > oIE.top = .parentWindow.screen.height\ 2 - 100 > .body.style.borderStyle = "outset" > .body.style.borderWidth = "3px" > .all.user.focus > .all.user.select > > ExtendedInfo = Array("CANCELLED") > > Do While .parentWindow.bBoxWait > > oSH.Appactivate "User's Extended Informations" > oIE.Visible = True > > if Err Then Exit Function > > WScript.Sleep 100 > > If .parentWindow.bBoxWait = "cancel" Then > > oIE.Visible = False > MsgBox(.parentWindow.bBoxWait) > Exit Do > End If > Loop > oIE.Visible = False > ExtendedInfo = Split(.all.user.value & "|" & .all.pass.value, "|") > End With ' document > End With ' IE > end function > > I just modified the function name and where the form is written (for > Employee #), and I'm always getting the following error message: > > Object doesn't support this property or method: 'all.user' > > and the referred line is .all.user.focus > > What's wrong with my VBScript??? > > Thanks. > > Claude Lachapelle > Systems Administrator, MCSE >
|
Pages: 1 Prev: More job id's in wsf file Next: Verifying IIS certificates |