Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input Data from Excel into already open webpage form

Status
Not open for further replies.

blckngldhwk

Technical User
Feb 14, 2008
46
US
I have searched extensively trying to find a solution to this but to no avail.

I cannot seem to find how to pull information from Excel and place it into an already open form in internet explorer.

I can find a hundred ways to open explorer, navigate to the url and input the data but that's not what I want.

Any suggestions?
 
faq707-6399

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
That's not really what I'm looking for. I don't have a problem looking through the source code, I already know the tags that I need to access. I just need to know how to activate an already open instance of Internet Explorer and then input information from Excel into the form.

I can AppActivate the IE window, but then I don't know how to interact with it at that point.

So I'm wondering if there is a simple command to do this.
 
Perhaps the not so reliable SendKeys function ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Here is an example that looks for an IE window that is pointing to a particular address, navigates to an input page, copies a value from the current sheet to the page and then submits the form on the page.
You'll have to play around with the strings to get it to work properly. Also, I wrote the form submit function to accomodate a javascript form checker, so you might have to change that line.
You'll also have to reference the 'Microsoft Internet Controls' library to access the ShDocVw and WebBrowser objects.

Code:
Sub CopyProductToWeb()
Dim objShell As SHDocVw.ShellWindows
Dim oIE As WebBrowser
Set objShell = New SHDocVw.ShellWindows
Set oIE = Nothing
For Each objwin In objShell
 If UCase(objwin.FullName) = UCase("C:\Program Files\Internet Explorer\iexplore.exe") Then
   If Left(UCase(objwin.LocationURL), Len("[URL unfurl="true"]http://www.example.com/index.htm"))[/URL] = UCase("[URL unfurl="true"]http://www.example.com/index.htm")[/URL] Then
     Set oIE = objwin
   End If
 End If
Next objwin
If TypeName(oIE) = "Nothing" Then
  MsgBox "Can't find target window"
  Exit Sub
End If
oIE.document.Navigate "[URL unfurl="true"]http://www.example.com/input.htm"[/URL]
Do Until oIE.Busy = False
  DoEvents
Loop
oIE.document.forms("FORM").elements("ProductNumber").Value = Cells(1, 1).Value
oIE.document.forms("FORM").onSubmit
End Sub
 
Here is what I went with

Code:
    AppTitle = "<Insert Title of IE window>"
    
    AppActivate AppTitle
        
    Set oApp = CreateObject("Shell.Application")
    
    For i = 0 To 25
    
        strName = ""
      
        On Error Resume Next
      
        strName = oApp.Windows(i).document.URL
      
        If InStr(strName, "<insert URL of IE window>") Then
        
            Set oIE = oApp.Windows(i)
            
            Exit For
            
        End If

    Next
    
    oIE.document.all("btnNewSearch").Click
    
    oIE.document.all("txtcert").Value = MbrID
    oIE.document.all("txtlname").Value = MbrLast
    oIE.document.all("txtfname").Value = MbrFirst
    
    oIE.document.all("btnsearch").Click
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top