Submitting w/o Submit button (Web)

Todd Bardoni

Well-known Member
Joined
Aug 29, 2002
Messages
3,042
I'm trying to query a webpage...

Excel enters the value into the field I want. To submit manually, I have to hit the Enter key since there is no command button on the webpage. How can I have Excel hit Enter automatically? Is this even clear?
 
Pasting it as text works for me--it's not formatted like the table, but the text does come across:

Code:
Sub Test()
Const url As String = "http://www.xpresswayplus.com/webapp/magec/servlet/Production"
Dim ie As Object

Set ie = CreateObject("internetexplorer.application")
With ie
    .Visible = False
    .Navigate url
    Do Until .ReadyState = 4: DoEvents:   Loop
    
    Set myTextField = .document.all.Item("txtPart")
    myTextField.Value = "1229G1619"
    .document.forms(0).submit
    Do Until .ReadyState = 4: DoEvents: Loop
    Do While .busy: DoEvents: Loop

    Do While .ReadyState <> 4
        DoEvents
    Loop
    .ExecWB 17, 2
    .ExecWB 12, 2
    ActiveSheet.PasteSpecial Format:="Text"
End With
End Sub
 
Upvote 0
Hey, that works for me as well.:)

Wonder if it's something to do with the websites.:huh:
 
Upvote 0
Yep , worked for me as well...and in fact, that is what I ended up going with...

Thanks!

this is the code I used for this particular project...it can be cleaned up a little, but it worked well for my purposes. I plan to modify it for a larger project I'm working on, so I'll probably clean up the code more at that time:

Code:
Sub WebQuery()
    With Application
        .EnableEvents = False
         .ScreenUpdating = False
        Set ie = CreateObject("InternetExplorer.Application")
        With ie
            For i = 2 To Sheets("Lamlinks").Range("A65536").End(xlUp).Row
                .Navigate "http://www.xpresswayplus.com/webapp/magec/servlet/Production"
                Do Until .ReadyState = 4: DoEvents: Loop
                Do While .busy: DoEvents: Loop
                Set myTextField = .document.all.Item("txtPart")
                myTextField.Value = Sheets("Lamlinks").Range("A" & i).Value
                .document.forms(0).submit
                Do Until .ReadyState = 4: DoEvents: Loop
                Do While .busy: DoEvents: Loop
                .ExecWB 17, 2
                .ExecWB 12, 2
                Sheets("Temp").Select
                ActiveSheet.PasteSpecial Format:="Text"
                myRows = Selection.Rows.Count
                Range("B1:B" & myRows).Value = Sheets("Lamlinks").Range("A" & i).Value
                Range("A1:B" & Range("A65536").End(xlUp).Row).Copy
                Sheets("Results").Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial
                Cells.Delete
                Range("A1").Select
            Next i
            .Quit
        End With
        .EnableEvents = True
        .ScreenUpdating = True
    End With
End Sub
 
Upvote 0
Todd

I know this issue is resolved and the thread quite old.:)

But I was helping another member today and I thought I'd go back and see if I could apply what I did to help them to this thread.

Anyway here's what I came up with.
Code:
Sub WebQuery()
Dim strProductTable

    Set ie = CreateObject("InternetExplorer.Application")
    With ie
        .Visible = True
        .navigate "http://www.xpresswayplus.com/webapp/magec/servlet/Production"
         Do Until .readyState = 4
             DoEvents
         Loop
         Set myTextField = .document.all.Item("txtPart")
         myTextField.Value = "1229G1619"
         ie.document.forms(0).submit
         Do Until .readyState = 4: DoEvents: Loop
         Do While .busy: DoEvents: Loop
         Set doc = ie.document
         
         For Each I In doc.all
             If I.nodename = "TABLE" Then
                 Set t = I
             End If
         Next I
         Set rng = Range("A1")
         For Each r In t.Rows
    
         For Each c In r.Cells
             rng.Value = c.innertext
             Set rng = rng.Offset(, 1)
             I = I + 1
         Next c
    
         Set rng = rng.Offset(1, -I)
         I = 0
         Next r
           
    End With
End Sub
 
Upvote 0
Hi what if you you were going to copy and paste the text but had to move the hightlight to a tab called reporting. I noticed through reading the blog that the person tried to search for the tab and submit it, I have the same problem and I tried a number of thing to tried to get to the tab including

Set myTextField = .document.all.Item("Reporting")
ie.document.forms(0).submit

But it does not work.
 
Upvote 0
Jim

What are you actually trying to do here?

Is this connected to your other thread?

If it is can you post to the original thread?
 
Upvote 0
Even if it isn't connected to the other thread, it really should be a *new* thread--not tacked onto this one.
 
Upvote 0
Todd

I know this issue is resolved and the thread quite old.:)

But I was helping another member today and I thought I'd go back and see if I could apply what I did to help them to this thread.

Anyway here's what I came up with.
Code:
Sub WebQuery()
Dim strProductTable

    Set ie = CreateObject("InternetExplorer.Application")
    With ie
        .Visible = True
        .navigate "http://www.xpresswayplus.com/webapp/magec/servlet/Production"
         Do Until .readyState = 4
             DoEvents
         Loop
         Set myTextField = .document.all.Item("txtPart")
         myTextField.Value = "1229G1619"
         ie.document.forms(0).submit
         Do Until .readyState = 4: DoEvents: Loop
         Do While .busy: DoEvents: Loop
         Set doc = ie.document
         
         For Each I In doc.all
             If I.nodename = "TABLE" Then
                 Set t = I
             End If
         Next I
         Set rng = Range("A1")
         For Each r In t.Rows
    
         For Each c In r.Cells
             rng.Value = c.innertext
             Set rng = rng.Offset(, 1)
             I = I + 1
         Next c
    
         Set rng = rng.Offset(1, -I)
         I = 0
         Next r
           
    End With
End Sub

Norie,
I just tried your code....you are a genius! I am implementing it ASAP.

Thank you.

By the way, where did you find the info for some of the items you used like "nodename "?
 
Upvote 0

Forum statistics

Threads
1,226,834
Messages
6,193,214
Members
453,779
Latest member
C_Rules

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top