By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,426 Members | 3,152 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,426 IT Pros & Developers. It's quick & easy.

Get Frame Collection

pod
100+
P: 298
Hi
I built a small tool in MS Access using a Form.

When I click a button on this form, I want it to search for any opened Internet Explorer (IE) window at a specific url and then input some value into a field in the form of that HTML page's document. The HTML document has frames.

I got the code to find the IE but now I am trying to get to the Frame collection on that HTML document.

Can anyone help me?


Thanks,

P :oD

Here is the code I use to find the IE window
Expand|Select|Wrap|Line Numbers
  1. 'finds an open IE site by checking the URL
  2. Function GetOpenIEByURL(ByVal i_URL As String) As SHDocVw.InternetExplorer
  3. Dim objShellWindows As New SHDocVw.ShellWindows
  4. Dim obj  As Object 'SHDocVw.InternetExplorer.iframes
  5.   'ignore errors when accessing the document property
  6.   On Error Resume Next
  7.   'loop over all Shell-Windows
  8.   For Each GetOpenIEByURL In objShellWindows
  9.     'if the document is of type HTMLDocument, it is an IE window
  10.     If TypeName(GetOpenIEByURL.Document) = "HTMLDocument" Then
  11.       'check the URL
  12.       If GetOpenIEByURL.Document.URL = i_URL Then
  13.         'we found the right window
  14.  
  15.         '---------
  16.         'need code here to get to the frame collection
  17.  
  18.         '....
  19.  
  20.         '---------
  21.         MsgBox "we found the right window"
  22.         Exit Function
  23.       End If
  24.     End If
  25.   Next
  26. End Function
  27.  
Jan 13 '10 #1

✓ answered by pod

FINALLY RESOLVED:
taking a few days break from a problem, always helps

here's the central missing portion

Expand|Select|Wrap|Line Numbers
  1. ...
  2.  
  3. Dim IEframes As FramesCollection
  4.     For Each GetOpenIEByURL In objShellWindows
  5.         'if the document is of type HTMLDocument, it is an IE window
  6.         If TypeName(GetOpenIEByURL.Document) = "HTMLDocument" Then
  7.             'check the URL
  8.             If InStr(GetOpenIEByURL.Document.url, i_URL) > 0 Then
  9.                 'I capture the outer frame
  10.                 Set IEframes = GetOpenIEByURL.Document.frames
  11.                 'I capture the inner frame
  12.                 Set IEframes = IEframes.Item(0)
  13.                 'now I want to capture the form and its elements and set them for submital
  14.                 IEframes(0).Document.Forms(0).SearchText.Value = 0
  15.                 IEframes(0).Document.Forms(0).SearchWhat.selectedIndex = 1
  16.                 IEframes(0).Document.Forms(0).HVQS_ACTION.Value = 1
  17.                 IEframes(0).Document.Forms(0).submit
  18.                 flag = True
  19.                 Exit Function
  20.             End If
  21.         End If
  22.     Next
  23.  

Share this Question
Share on Google+
3 Replies


ADezii
Expert 5K+
P: 8,638
It is my understanding that it would be something similar to:
Expand|Select|Wrap|Line Numbers
  1. Dim intFrameCounter As Integer
  2.  
  3. For intFrameCounter = 0 To Document.Frames.Length - 1
  4.   MsgBox Frames(intFrameCounter).Location.href
  5. Next
Jan 14 '10 #2

pod
100+
P: 298
pod
thanks ADezii for answering to my query, I have yet to achieve my main goal, accessing the form elements to change their values for submittal of the form.

I have made some headway but I still need help. See the code below .

Thank you all in advance for your help. If I figure this one out on my own, I will post my result for everybody's benefit.

P :oD

Here is my updated code:

Expand|Select|Wrap|Line Numbers
  1. 'finds an open IE site by checking the URL
  2. Function GetOpenIEByURL(ByVal i_URL As String) As SHDocVw.WebBrowser
  3.     Dim i_URL As String
  4.     Dim objIE As Object
  5.     Dim objShellWindows As New SHDocVw.ShellWindows
  6.     'some error handling
  7.     On Error GoTo catchError
  8.     'loop over all Shell-Windows
  9.     Dim IEframes As FramesCollection
  10.     For Each GetOpenIEByURL In objShellWindows
  11.     'if the document is of type HTMLDocument, it is an IE window
  12.     If TypeName(GetOpenIEByURL.Document) = "HTMLDocument" Then
  13.         'check the URL
  14.         If InStr(GetOpenIEByURL.Document.url, i_URL) > 0 Then
  15.             'we found the right IE window
  16.  
  17.             'now I capture the outer frame of the HTML document
  18.             Set IEframes = GetOpenIEByURL.Document.frames
  19.             ' and now I capture the inner frame
  20.             Set IEframes = IEframes.Item(0)
  21.             'this is the frame which contains the form
  22.             MsgBox IEframes(0).Name 'this is the one
  23.  
  24. '...so far so good
  25. 'NEED THE RIGHT CODE HERE
  26.  
  27.             'now I want to capture the form
  28.             '....Dim IEForm as GetTheElusiveFormCollection 
  29.             'and capture a text box in the form to set a value to it
  30.             '....Dim IEForm as GetTheElusiveFormFieldCollection 
  31.  
  32.  
  33.  
  34.  
  35.             Exit Function
  36.         End If
  37.     End If
  38.     Next
  39. catchError:
  40.     MsgBox Err.Description
  41. '    Call GetNewIE
  42. End Function
  43.  
  44.  
p.s.
God's speed to the people of Haiti and all the people who are helping out in any way or fashion
Jan 15 '10 #3

pod
100+
P: 298
pod
FINALLY RESOLVED:
taking a few days break from a problem, always helps

here's the central missing portion

Expand|Select|Wrap|Line Numbers
  1. ...
  2.  
  3. Dim IEframes As FramesCollection
  4.     For Each GetOpenIEByURL In objShellWindows
  5.         'if the document is of type HTMLDocument, it is an IE window
  6.         If TypeName(GetOpenIEByURL.Document) = "HTMLDocument" Then
  7.             'check the URL
  8.             If InStr(GetOpenIEByURL.Document.url, i_URL) > 0 Then
  9.                 'I capture the outer frame
  10.                 Set IEframes = GetOpenIEByURL.Document.frames
  11.                 'I capture the inner frame
  12.                 Set IEframes = IEframes.Item(0)
  13.                 'now I want to capture the form and its elements and set them for submital
  14.                 IEframes(0).Document.Forms(0).SearchText.Value = 0
  15.                 IEframes(0).Document.Forms(0).SearchWhat.selectedIndex = 1
  16.                 IEframes(0).Document.Forms(0).HVQS_ACTION.Value = 1
  17.                 IEframes(0).Document.Forms(0).submit
  18.                 flag = True
  19.                 Exit Function
  20.             End If
  21.         End If
  22.     Next
  23.  
Jan 21 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.