Results 1 to 3 of 3

Thread: Reference lHwnd to an object

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2007
    Posts
    35

    Reference lHwnd to an object

    I will try and explain this the best way I can:-

    I have the following code
    Code:
    Private Declare Function FindWindow _
    Lib "user32" _
    Alias "FindWindowA" _
    (ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long
    Private Declare Function ShowWindow _
    Lib "user32" _
    (ByVal hwnd As Long, _
    ByVal nCmdShow As Long) As Long
    Private Const SW_SHOWNORMAL = 1
    Private Const SW_SHOWMINIMIZED = 2
    Private Const SW_SHOWMAXIMIZED = 3
    Private Sub Command1_Click()
    Dim lHwnd As Long
    Dim objIE As Object
    
    lHwnd = FindWindow(vbNullString, ByVal "Google - Microsoft Internet Explorer")
    If lHwnd <> 0 Then
    MsgBox "IE Window is open!", vbInformation, "Google"
    ShowWindow lHwnd, SW_SHOWNORMAL
    'objIE = lHwnd
    'objIE.document.Form("q").Value = "test"
    Else
    MsgBox "Internet Explorer isn't open!", vbInformation, "Window not found."
    
    
    
    End If
    
    End Sub
    Which finds and returns an open Internet Explorer window.
    I have tried to create a reference to lHwnd as an object using the code in bold.
    Because i want to input some data in a form on the required web page. Using 'objIE.document.Form("q").Value = "test"

    But I keep getting an error saying object variable or with block variable not set.

    Is it possible to make an object reference to lHwnd.
    I am using Google as test website, to get me familiar with forms.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Reference lHwnd to an object

    I'm guessing that objIE is the object that is causing the problem.

    I see you creating it but I don't see you setting it to anything.

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2007
    Posts
    35

    Re: Reference lHwnd to an object

    I can create it ok as an object. Can i use Set objIE = lHwnd

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width