Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Problem with Shell.Application in HTA

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,49898
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Problem with Shell.Application in HTA
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 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>
 
 
Post #: 1
 
 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

(in reply to zekedawg)
 
 
Post #: 2
 
 RE: Problem with Shell.Application in HTA - 7/25/2007 3:47:00 AM   
  zekedawg

 

Posts: 3
Score: 0
Joined: 7/24/2007
Status: offline
Line 141 Char 1 is giving me the error of ActiveX component can't create object.
For Each w in shellApp.Windows

I am using Windows XP Professional Service Pack 2.
If I comment the part where Shell.Application is created, then I get the error that the object for ShellApp is required.


This was working but all of sudden stopped.  I have this almost very same project in a vbscript and it is also acting up.  I should try this on another machine at work to see if I can reproduce these same results..

(in reply to dm_4ever)
 
 
Post #: 3
 
 RE: Problem with Shell.Application in HTA - 7/25/2007 4:20:20 AM   
  zekedawg

 

Posts: 3
Score: 0
Joined: 7/24/2007
Status: offline
Hey dm_4ever,

I found out the problem and now everything works with no errors. I recently modified my explorer.exe file using reshack located in the C:\Window folder to customize Windows on my WORK computer (for testing purposes of course).  It looks like this broke my search feature in the start menu and also my script.

Thanks for making me see the light.

(in reply to zekedawg)
 
 
Post #: 4
 
 RE: Problem with Shell.Application in HTA - 7/25/2007 7:47:12 AM   
  dm_4ever


Posts: 2663
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Glad to here you were able to fix the 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

(in reply to zekedawg)
 
 
Post #: 5
 
 RE: Problem with Shell.Application in HTA - 12/24/2007 8:31:59 AM   
  kbsudhir

 

Posts: 1
Score: 0
Joined: 12/24/2007
Status: offline
 
Hi

I am trying to run a set of instructions on a website, ex Extracting data from the websiteto excel sheet, from one particular website out a number of other website which opened.

Ex. I want to extract some data from vbaexpress website.

I have to determine which is that website out of all the websites which are opened.

This is the code for that -

Function GetIEApp() As Object
Dim objShell As Object
Dim objWindows As Object
Dim objWindow As Object
Dim lngSingleWindow As Long
Dim intOption As Integer
Dim strMessage As String, strReturnValue As String
Set objShell = CreateObject("Shell.Application")
Set objWindows = objShell.Windows
lngSingleWindow = -1
For Each objWindow In objWindows
'Build a list of windows, make sure they are Internet Explorer
If (objWindow.LocationName = "VBA Express Forum") Then
Debug.Print objWindow.LocationName
MsgBox (objWindow.LocationName)
Set GetIEApp = objWindow
Exit For
End If
Next objWindow
End Function

Refrences used is
1. Visual Basic For Applications
2. Microsoft Excel 11.0 Object Library
3. OLE Automation
4. Microsoft Office 11.0 Object Library
5. Microsoft Internet Controls
6. Microsoft HTML Object Library

But when I run this code I get the following error:

"ActiveX Component Can't create object"

When the Line - "Set objWindows = objShell.Windows" is executed.
Can anyone tell me the reason and also the resolution for this error.

 
 I have read the above but I work in a client server environment using citrix client end, to any access to any office applications. I don't have access to C:
 Even though I am creating a macro in excel but the error is of similar kind hence please help


Anyhelp regarding the same is very helpful.



Thanks
Sudhir



_____________________________

Sudhir

(in reply to dm_4ever)
 
 
Post #: 6
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Problem with Shell.Application in HTA Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts