|
Post by Alexander on Jan 21, 2004 20:58:46 GMT -5
Ive been working on this for hours and im really getting annoyed cause i cant get it to work...
How the heck can i get the contents of the address bars of any internet explorers open?
|
|
|
Post by Webagent on Jan 22, 2004 0:39:09 GMT -5
How the heck can i get the contents of the address bars of any internet explorers open? I dont understand your question, you mean the URL link in the IE adress bar? and then what to do to open that link?
|
|
|
Post by Webagent on Jan 22, 2004 0:47:01 GMT -5
maybe you can use .LocationURL from shdocvw.dll or use this Bas file www.mvps.org/access/downloads/inetexplorer.bas www.mvps.org/access/api/api0051.htm <-- If we want to read URLs and window captions of open IE windows on the desktop, we can also use a few API functions that locate the Address text box in the IE window and retrieve the text (URL) currently being displayed there. www.mvps.org/access/modules/mdl0062.htm <-- Microsoft Internet Explorer comes with a fairly comprehensive, although sparsely documented, Object Model. If you've used the Web Browser control in Access, you are already familiar with the capabilities of IE's Object Model. All of the functionality in IE's object model (not counting external support, like scripting support etc.) is provided by the following two dlls br] shdocvw.dll (Microsoft Internet Controls) mshtml.tlb (Microsoft HTML Object Library) You can automate IE to save a HTML file locally (read the comments in the code), inspect all the elements, and parse out a particular item at runtime. Here's some sample code that loops through all the IE windows currently open looking for a browser that has the string URL_TO_SEARCH in it's address bar. If it finds such a window, it prompts the user to save the HTML as a local file. Additionally, it will go through all the HTML elements in that page and try to find an anchor whose description is ANCHOR_DESC_TO_SEARCH. If it finds this element, it will print out the URL the anchor is pointing to in the debug window. (Also look at the article API: Read-Set Internet Explorer URL from code for an API approach under a somewhat similar scenario.) ' ****** Code Start ********* 'This code was originally written by Dev Ashish 'It is not to be altered or distributed, 'except as part of an application. 'You are free to use it in any application, 'provided the copyright notice is left unchanged. ' 'Code Courtesy of 'Dev Ashish ' Sub sTestIEAutomation() ' Requires two references ' shdocvw.dll - Microsoft Internet Controls ' mshtml.tlb - Microsoft HTML Object Library ' On Error GoTo ErrHandler Dim objShellWins As SHDocVw.ShellWindows Dim objIE As SHDocVw.InternetExplorer Dim objDoc As Object Dim i As Integer Dim strOut As String Dim intFree As Integer Dim clsDialog As CDialog ' Wrapper around GetOpen/SaveFileName Const URL_TO_SEARCH = "http://www.mvps.org/access" Const ANCHOR_DESC_TO_SEARCH = "Comprehensive Links"
' Instantiate Set objShellWins = New SHDocVw.ShellWindows ' There might be multiple IE windows open For Each objIE In objShellWins With objIE ' Try to locate the browser with a specific address ' in it's AddressBar. You can also Navigate to a new ' address If (InStr(1, _ .LocationURL, _ URL_TO_SEARCH, vbTextCompare)) Then ' Get a reference to the HTMLDocument contained within ' the InternetExplorer instance Set objDoc = .Document If (TypeOf objDoc Is HTMLDocument) Then ' Limitations of running the following command[img]http://proboards8.com/boardimages/sad.gif[/img]br] ' Call objIE.ExecWB( _ OLECMDID_SAVEAS, _ OLECMDEXECOPT_PROMPTUSER) ' IE's "SaveAs" dialog doesn't allow you to ' retrieve the filename the user typed in ' so use our own code for the SaveAs dialog ' The CDialog class is simply a wrapper around ' the code listed at the following URL ' http://www.mvps.org/access/api/api0001.htm ' Set clsDialog = New CDialog With clsDialog .hWnd = hWndAccessApp .StartDir = CurDir .ModeOpen = False .DefaultExtension = "htm" .Title = "Please select a folder to save the file" .Filter = "HTML Files (*.htm, *.html)|*.htm" strOut = .Action End With If Len(strOut) Then ' Now that we have a filename, ' Save out the HTML as a persisted file intFree = FreeFile Open strOut For Output As #intFree Write #intFree, objDoc.body.parentElement.innerHTML Close #intFree ' Alternatively, you could also just ' inpect the HTM at runtime via the property With objDoc.all For i = 1 To .Length If (TypeOf .Item(i) Is HTMLAnchorElement) Then If .Item(i).nodeName = "A" Then ' Only look for a link which has the description ' "Comprehensive Links" attached to it If (InStr(1, _ .Item(i).innerText, _ ANCHOR_DESC_TO_SEARCH, _ vbTextCompare)) Then ' Print out the URL Debug.Print objDoc.all.Item(i).href ' Bail out Exit For End If End If End If Next End With End If End If Exit For End If End With Next ExitHere[img]http://proboards8.com/boardimages/sad.gif[/img]br] On Error Resume Next Close #intFree Set clsDialog = Nothing Set objDoc = Nothing Set objIE = Nothing Set objShellWins = Nothing Exit Sub ErrHandler[img]http://proboards8.com/boardimages/sad.gif[/img]br] With Err MsgBox "Error: " & .Number & vbCrLf & .Description, _ vbCritical Or vbOKOnly, .Source End With Resume ExitHere End Sub ' ****** Code End *********
|
|
|
Post by Dangermouse on Jan 22, 2004 5:16:19 GMT -5
' Bail out Exit For End If End If End If Next End With End If End If Exit For End If End With Lol
|
|
|
Post by Freak on Jan 22, 2004 12:36:35 GMT -5
looks secxyer when properly intented
|
|
|
Post by Lazer on Jan 22, 2004 12:48:11 GMT -5
unload me
|
|
|
Post by Armstrong on Jan 22, 2004 17:57:20 GMT -5
Add a reference to SHDocVw.dll, add a listbox, and a command button. Then add this code under the click event of the command button.
Dim oIE As SHDocVw.InternetExplorer Dim oSWin As New SHDocVw.ShellWindows
List1.Clear
For Each oIE In oSWin List1.AddItem oIE.LocationURL Next
|
|
|
Post by Alexander on Jan 24, 2004 2:21:50 GMT -5
cheers everyone got it working its looking real perdy
|
|