VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Gets the URL string from the ie browser edit window. This also works in access97 vba. I put it in o

by C Labitan, Jr. MD (1 Submission)
Category: Internet/HTML
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Mon 11th October 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Gets the URL string from the ie browser edit window. This also works in access97 vba. I put it in one subroutine to keep things simple and

API Declarations



Private Declare Function shellexecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As _
String, ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessageLong& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
Private Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Const WM_USER = &H400
Const EM_LIMITTEXT = WM_USER + 21
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE
Private Const EM_GETLINECOUNT = &HBA
Private Const EM_LINEINDEX = &HBB
Private Const EM_LINELENGTH = &HC1

Rate Gets the URL string from the ie browser edit window. This also works in access97 vba. I put it in o




 On Error GoTo CallErrorA
    Dim iPos As Integer
    Dim sClassName As String
    Dim GetAddressText As String
    Dim lhwnd As Long
    Dim WindowHandle As Long
    
   lhwnd = 0
   sClassName = ("IEFrame")
   lhwnd = FindWindowEx(lhwnd, 0, sClassName, vbNullString)
   sClassName = ("WorkerA")
   lhwnd = FindWindowEx(lhwnd, 0, sClassName, vbNullString)
   sClassName = ("ReBarWindow32")
   lhwnd = FindWindowEx(lhwnd, 0, sClassName, vbNullString)
   sClassName = ("ComboBoxEx32")
   lhwnd = FindWindowEx(lhwnd, 0, sClassName, vbNullString)
   sClassName = ("ComboBox")
   lhwnd = FindWindowEx(lhwnd, 0, sClassName, vbNullString)
   sClassName = ("Edit")
   lhwnd = FindWindowEx(lhwnd, 0, sClassName, vbNullString)
        
        WindowHandle& = lhwnd
        Dim buffer As String, TextLength As Long
        TextLength& = SendMessage(WindowHandle&, WM_GETTEXTLENGTH, 0&, 0&)
        buffer$ = String(TextLength&, 0&)
        Call SendMessageByString(WindowHandle&, WM_GETTEXT, TextLength& + 1, buffer$)
        MsgBox buffer$

   Exit Sub
CallErrorA:
    MsgBox Err.Description
    Err.Clear

End Sub

Download this snippet    Add to My Saved Code

Gets the URL string from the ie browser edit window. This also works in access97 vba. I put it in o Comments

No comments have been posted about Gets the URL string from the ie browser edit window. This also works in access97 vba. I put it in o. Why not be the first to post a comment about Gets the URL string from the ie browser edit window. This also works in access97 vba. I put it in o.

Post your comment

Subject:
Message:
0/1000 characters