Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Microsoft Internet Explorer _ Copy The Current Internet Explorer URL To A Field

Posted by: BuzyG Dec 6 2017, 08:42 AM

Hello again folks. I'm hoping this one is straight forward.

I have internet Explorer 11 open and simply need to copy the current URL from the address bar, into a field, [DiscLink], on the current form. The Microsoft Internet controls Library is loaded.

Presently this is what I have, alas it does not work.

CODE
Private Sub btnGetURL_Click()

  Dim IE As SHDocVw.InternetExplorer
  Dim StrURL As String

  StrURL = IE.LocationURL
  Me![DiscLink] = StrURL

End Sub

Posted by: GroverParkGeorge Dec 6 2017, 08:52 AM

What does it mean to say it doesn't work? Wrong URL? No URL? Nothing pasted into the table or ?


Posted by: DanielPineault Dec 6 2017, 09:00 AM

Perhaps this could help.

http://www.devhut.net/2017/02/03/internet-explorer-save-tabs/

Posted by: BuzyG Dec 6 2017, 09:00 AM

A fine question George. Apparently my wishing for it does not make others telepathic.


Object Variable or with Block Variable not set occurs at...

StrURL = IE.LocationURL

Posted by: GroverParkGeorge Dec 6 2017, 09:20 AM

Sweet.

Posted by: BuzyG Dec 6 2017, 11:14 AM

Thanks Daniel notworthy.gif

I just needed to bind to the current instance of IE 11. I had been trying to use the Get Object Method, which I now know doesn't work for IE. Hence why the 'Microsoft Internet Controls' Library needs to be Open.

Final code was...

CODE
Dim SW As SHDocVw.ShellWindows
Dim IE As SHDocVw.InternetExplorer
Dim StrURL As String
  
  Set SW = New SHDocVw.ShellWindows
  For Each IE In SW
    If IE.NAME = "Internet Explorer" Then
      StrURL = IE.LocationURL
      Me![DiscLink] = StrURL
    End If
  Next
Set SW = Nothing
Set IE = Nothing

Posted by: DanielPineault Dec 6 2017, 01:47 PM

thumbup.gif

Yeah, I remember having that issue when I develop my code a while back. Ah, fun times...!