Login | |
|
 |
Problem with Shell.Application in HTA - 7/24/2007 4:25:34 AM
|
|
 |
|
| |
zekedawg
Posts: 3
Score: 0
Joined: 7/24/2007
Status: offline
|
Hello World. I am new user to this forum and was wondering if anyone has had the same issues I have had. My HTA file stopped working suddenly and now it reports an ActiveX component can't create object. My HTA errors when I create an object for Shell.Application. I was working on another project and had this same problem as well, but I managed to add the OBJECT tag for my WScript.Shell.1 compononent to fix this problem. I know this was working, but if I can't use Shell.Application, then what other method can I use to search through each IE window for a specific URL. I have included my source below. <HTA:APPLICATION ID="objXML" APPLICATIONNAME="XMLGrabber" MAXIMIZEBUTTON="NO" SCROLL="no" SINGLEINSTANCE="yes"> <TITLE>XML Grabber by Zeke</TITLE> <SCRIPT LANGUAGE="VBScript"> Sub Window_onLoad dim winHeight dim winWidth dim centerX dim centerY winWidth=350 winHeight=440 centerX=(screen.width/2)-(winWidth/2) centerY=(screen.height/2)-(winHeight/2) window.resizeto winWidth,winHeight window.moveto centerX,centerY End Sub Sub GrabXML Dim strEnvironment Dim strEntireURL Dim strXMLValue Dim objShell Dim shellApp Dim StatusText Dim FirstPeriod Dim ApplicationID Dim SecondPeriod Dim ThirdPeriod Dim LengthStatus Dim LoanID Dim CoBorrowerInd Dim NoWebPageExists If Environment.Value = "http://pt-sfc-test:9000" Then strEnvironment = Environment.Value strEntireURL = "/Prelim/Dashboard/Default.aspx" strEntireURL = strEnvironment & "" & strEntireURL End if If Environment.Value = "http://ca-rls-dev-wb:4430" Then strEnvironment = Environment.Value strEntireURL = "/Prelim/Dashboard/Default.aspx" strEntireURL = strEnvironment & "" & strEntireURL End if If Environment.Value = "http://ca-rls-dev-wb:2620" Then strEnvironment = Environment.Value strEntireURL = "/Prelim/Dashboard/Default.aspx" strEntireURL = strEnvironment & "" & strEntireURL End if If Environment.Value = "http://ca-rls-dev-wb:7625" Then strEnvironment = Environment.Value strEntireURL = "/Prelim/Dashboard/Default.aspx" strEntireURL = strEnvironment & "" & strEntireURL End if If Environment.Value = "http://ca-rls-dev-wb:2554" Then strEnvironment = Environment.Value strEntireURL = "/Prelim/Dashboard/Default.aspx" strEntireURL = strEnvironment & "" & strEntireURL End if If Environment.Value = "http://ca-rls-dev-wb:7320" Then strEnvironment = Environment.Value strEntireURL = "/Prelim/Dashboard/Default.aspx" strEntireURL = strEnvironment & "" & strEntireURL End if If Environment.Value = "" Then Msgbox "Please select an environment for which you need to pull a XML from." Exit Sub End If If XML(0).Checked Then strXMLValue = XML(0).Value CoBorrowerInd = 0 End if If XML(1).Checked Then strXMLValue = XML(1).Value CoBorrowerInd = 0 End if If XML(2).Checked Then strXMLValue = XML(2).Value CoBorrowerInd = 0 End if If XML(3).Checked Then strXMLValue = XML(3).Value CoBorrowerInd = 0 End if If XML(4).Checked Then strXMLValue = XML(4).Value CoBorrowerInd = 0 End if If XML(5).Checked Then strXMLValue = XML(5).Value CoBorrowerInd = 0 End if If XML(6).Checked Then strXMLValue = XML(6).Value CoBorrowerInd = 1 End if If XML(7).Checked Then strXMLValue = XML(7).Value CoBorrowerInd = 1 End if If strXMLValue = "" Then Msgbox "Please select which type of XML to pull." Exit Sub End If Set shellApp = CreateObject("Shell.Application") For Each w in shellApp.Windows If lcase(typename(w.document)) = "htmldocument" AND w.LocationURL = strEntireURL then NoWebPageExists = 0 StatusText = w.StatusText If CoBorrowerInd = 0 Then FirstPeriod = Instr(StatusText,".") ApplicationID = Mid(StatusText,1,(FirstPeriod - 1)) SecondPeriod = Instr((FirstPeriod + 1), StatusText, ".") LoanID = Mid(StatusText,(FirstPeriod + 1),(SecondPeriod - 1) - FirstPeriod) Else FirstPeriod = Instr(StatusText,".") ApplicationID = Mid(StatusText,1,(FirstPeriod - 1)) SecondPeriod = Instr((FirstPeriod + 1), StatusText, ".") ThirdPeriod = Instr((SecondPeriod + 1), StatusText, ".") LengthStatus = ((Len(StatusText) - 2) - ThirdPeriod) LoanID = Mid(StatusText,(ThirdPeriod + 1),LengthStatus) End If Set objShell = CreateObject("WScript.Shell") objShell.Run(strEnvironment & "/includes/getxml.aspx?appid=" & ApplicationID & "&lnappid=" & LoanID & "&type=" & strXMLValue) Else If lcase(typename(w.document)) = "htmldocument" AND w.LocationURL <> strEntireURL then NoWebPageExists = 1 End If End If next If NoWebPageExists = 1 Then Msgbox "No web browser is viewing " & strEntireURL & "." End If End Sub </SCRIPT> <HTML> <BODY STYLE="font:12 pt georgia; color:white; filter:progid:DXImageTransform.Microsoft.Gradient (GradientType=1, StartColorStr='#000000', EndColorStr='#025490')"> <table width="100%" border=12 bordercolorlight="#025490" bordercolordark="#025490"> <tr align=left><td><P ALIGN=center><font face=georgia><b>Select your Environment.</font></b><br><br> <SELECT NAME="Environment"> <OPTION VALUE=""> <OPTION VALUE="http://pt-sfc-test:9000'>http://pt-sfc-test:9000">http://pt-sfc-test:9000 <OPTION VALUE="http://ca-rls-dev-wb:4430'>http://ca-rls-dev-wb:4430">http://ca-rls-dev-wb:4430 <OPTION VALUE="http://ca-rls-dev-wb:2620'>http://ca-rls-dev-wb:2620">http://ca-rls-dev-wb:2620 <OPTION VALUE="http://ca-rls-dev-wb:7625'>http://ca-rls-dev-wb:7625">http://ca-rls-dev-wb:7625 <OPTION VALUE="http://ca-rls-dev-wb:2554'>http://ca-rls-dev-wb:2554">http://ca-rls-dev-wb:2554 <OPTION VALUE="http://ca-rls-dev-wb:7320'>http://ca-rls-dev-wb:7320">http://ca-rls-dev-wb:7320 </SELECT> <br><br> <font face=georgia><b>Select XML to Pull.</b><br></font><br><P> <P ALIGN=left> <INPUT TYPE=RADIO NAME="XML" VALUE="du">DU Xml<br> <INPUT TYPE=RADIO NAME="XML" VALUE="credit">Credit Xml<br> <INPUT TYPE=RADIO NAME="XML" VALUE="fund">Funding Xml<br> <INPUT TYPE=RADIO NAME="XML" VALUE="shipping">Shipping Xml<br> <INPUT TYPE=RADIO NAME="XML" VALUE="register">Register Xml<br> <INPUT TYPE=RADIO NAME="XML" VALUE="response">Response Xml<br> <INPUT TYPE=RADIO NAME="XML" VALUE="du">Co-Borrower DU Xml<br> <INPUT TYPE=RADIO NAME="XML" VALUE="credit">Co-Borrower Credit Xml<br><br><P> </table> <table width="100%" border=12 bordercolorlight="#025490" bordercolordark="#025490"> <tr><td align=center><input id=runbutton class="button" type="button" value="Grab XML" style="width:100px" name="cancel_button" onClick="GrabXML"></td></tr> </table> </BODY> </HTML>
|
|
| |
|
|
|
 |
RE: Problem with Shell.Application in HTA - 7/24/2007 1:46:37 PM
|
|
 |
|
| |
dm_4ever
Posts: 2663
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
|
What line is giving you the error? What OS are you using? I commented everything but the part where Shell.Application is created and had it show me the LocationURL for each open window without an issue.
_____________________________
dm_4ever My philosophy: K.I.S.S - Keep It Simple Stupid Read Me: http://www.visualbasicscript.com/m_24727/tm.htm Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|