Filling out webform using VBA

colangeloc

New Member
Joined
Sep 27, 2015
Messages
8
Hello,

I am currently running into a problem when trying inputting code into a web form. The code I have works fine for entering in the information but I am getting an error from the system stating that the entry is invalid even though its correct. If I copy and past into this field the website reformats the data. I have tried making vba input the data in the exact same format without any luck. The website is a company internal so I can't post to much details.

Code:
Sub populateform()
marker = 0
Set objShell = CreateObject("Shell.Application")
IE_count = objShell.Windows.Count
For x = 0 To (IE_count - 1)
    On Error Resume Next    ' sometimes more web pages are counted than are open
    my_url = objShell.Windows(x).******************
    my_title = objShell.Windows(x).Document.Title

    If my_title Like "Add New Discrepancy" & "*" Then 'compare to find if the desired web page is already open
        Set IE = objShell.Windows(x)
        marker = 1
        Exit For
    Else
    End If
Next




IE.Document.all("mobileID").Value = ThisWorkbook.Sheets(1).range("a2")
IE.Document.getElementById("customerName").Value = ThisWorkbook.Sheets("sheet1").range("b2")



End Sub

I am having an issue with both the mobile ID & customer name. again vba enters the info but the website is not taking it the same way as if I copy any paste.



Code:
<input id="mobileID" type="text" maxlength="15" data-bind="phoneValue: MOBILE_ID, click: mobileIdFocusFn, hasFocus: mobileIdHasFocus">

Code:
<input id="customerName" type="text" maxlength="25" data-bind="value: CUSTOMER_NAME, click: customerNameFocusFn, hasFocus: customerNameHasFocus">
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I did the wrong code wrap above.

HTML:
<input id="customerName" type="text" maxlength="25" data-bind="value: CUSTOMER_NAME, click: customerNameFocusFn, hasFocus: customerNameHasFocus">

HTML:
<input id="mobileID" type="text" maxlength="15" data-bind="phoneValue: MOBILE_ID, click: mobileIdFocusFn, hasFocus: mobileIdHasFocus">
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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