Import Excel Spreadsheet Data into an ASP.net webform form using VBA

0

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:

Excel

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

Rosco

Posted 2018-04-12T14:05:18.610

Reputation: 13

Answers

0

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

iframe:

iframe

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"
            .querySelector("input[type=submit]").Click
        End With
        '.Quit '<== Remember to quit application
    End With
End Sub

user778123

Posted 2018-04-12T14:05:18.610

Reputation: