I am trying to use Excel VBA to export data from a spreadsheet into an aspx online form and submit it.

Example: I have a spreadsheet with column A titled "NAME". The rows are populated with the corresponding data. Also I have a url that leads to an asp.net webform. The webform has a field for "Your Name". I would like to run a macro that will:

  1. launch Internet Explorer
  2. navigate to the asp webform url
  3. populate the webform fields with the corresponding data from row 2 of the excel spreadsheet
  4. click the submit button
  5. repeat until all rows are submitted

Excel spreadsheet:


Link to webform

I have come across tutorials on how to do this for HTML but none on asp webforms and apparently others have requested help on this same subject before: Link.

Here is the code I've cobbled together so far and the error I'm getting. Any advice would be greatly appreciated. Also I feel its necessary to state that I am very much a novice, so layman's terms please.

VBA Error


Your problem is that there is an iframe to navigate in order to perform your tasks:



Your code needs to navigate this, for example:

Option Explicit
Public Sub SubmitInfo()
    Dim IE As New InternetExplorer
    With IE
        .Visible = True
        .navigate "https://www.w3schools.com/asp/showasphtmfile.asp?filename=demo_reqquery"

        While .Busy Or .readyState < 4: DoEvents: Wend
        With .document.getElementsByTagName("iframe")(0).contentDocument
            .querySelector("input[type=text]").Value = "blah"
        End With
        '.Quit '<== Remember to quit application
    End With
End Sub

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.