Excel VBA controlling Internet Explorer Form fields

msdst16

New Member
Joined
Aug 11, 2010
Messages
2
I'm trying to use a macro to go to a webpage and pull some information out and then change a field for a large number of users. I'm able to get most of the fields to change with the exception of one field. Any advice would be helpful.

The desire would be to change S1 to S3. It does it when I view the page but doesn't actually save the S3 it always reverts back to S1.

VBA Code:
Code:
Sub Login_2_Website()
Dim oHTML_Element As IHTMLElement
Dim sURL As String
On Error GoTo Err_Clear
 
 
    sURL = [URL="http://www.theeditwebpage.com/"]www.theeditwebpage.com[/URL]
    oBrowser.Silent = True
    oBrowser.timeout = 60
    oBrowser.navigate sURL
    oBrowser.Visible = True
 
    Do
    ' Wait till the Browser is loaded
    Loop Until oBrowser.readyState = READYSTATE_COMPLETE
 
    HTMLDoc.all.txttxtInformal.Value = "NickName"
    HTMLDoc.all.txttxtDesignation.Value = "S3"
 
    For Each oHTML_Element In HTMLDoc.getElementsByTagName("input")
    If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit For
    Next    
 
' oBrowser.Refresh ' Refresh If Needed
Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If
End Sub

The source code from webpage:
value causing problem
Code:
[COLOR=red][FONT=Courier New]<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>[/FONT][/COLOR]
[COLOR=red][FONT=Courier New]id[/FONT][/COLOR][COLOR=blue][FONT=Courier New]="serDesignation"><[/FONT][/COLOR][COLOR=maroon][FONT=Courier New]tr[/FONT][/COLOR][COLOR=blue][FONT=Courier New]>[/FONT][/COLOR][FONT=Courier New]<o:p></o:p>[/FONT]
[COLOR=blue][FONT=Courier New]<[/FONT][/COLOR][COLOR=maroon][FONT=Courier New]td[/FONT][/COLOR][COLOR=red][FONT=Courier New]class[/FONT][/COLOR][COLOR=blue][FONT=Courier New]="isg_formLabel" [/FONT][/COLOR][COLOR=red][FONT=Courier New]style[/FONT][/COLOR][COLOR=blue][FONT=Courier New]="width:30%;"><[/FONT][/COLOR][COLOR=maroon][FONT=Courier New]span[/FONT][/COLOR][COLOR=red][FONT=Courier New]id[/FONT][/COLOR][COLOR=blue][FONT=Courier New]="lblDesignation">[/FONT][/COLOR][COLOR=black][FONT=Courier New]Designation[/FONT][/COLOR][COLOR=blue][FONT=Courier New]</< font>[/FONT][COLOR=maroon][FONT=Courier New]span[/FONT][/COLOR][COLOR=blue][FONT=Courier New]><[/FONT][/COLOR][COLOR=maroon][FONT=Courier New]em[/FONT][/COLOR][COLOR=red][FONT=Courier New]class[/FONT][/COLOR][COLOR=blue][FONT=Courier New]="isg_sectionInstructions"><[/FONT][/COLOR][COLOR=maroon][FONT=Courier New]BR[/FONT][/COLOR][COLOR=blue][FONT=Courier New]>[/FONT][/COLOR][COLOR=black][FONT=Courier New]Read-Only[/FONT][/COLOR][COLOR=blue][FONT=Courier New]</< font>[/FONT][COLOR=maroon][FONT=Courier New]em[/FONT][/COLOR][COLOR=blue][FONT=Courier New]></< font>[/FONT][COLOR=maroon][FONT=Courier New]td[/FONT][/COLOR][COLOR=blue][FONT=Courier New]><[/FONT][/COLOR][COLOR=maroon][FONT=Courier New]td[/FONT][/COLOR][COLOR=red][FONT=Courier New]class[/FONT][/COLOR][COLOR=blue][FONT=Courier New]="isg_formData" [/FONT][/COLOR][COLOR=red][FONT=Courier New]colspan[/FONT][/COLOR][COLOR=blue][FONT=Courier New]="1" [/FONT][/COLOR][COLOR=red][FONT=Courier New]style[/FONT][/COLOR][COLOR=blue][FONT=Courier New]="width:70%;"><[/FONT][/COLOR][COLOR=maroon][FONT=Courier New]span[/FONT][/COLOR][COLOR=red][FONT=Courier New]id[/FONT][/COLOR][COLOR=blue][FONT=Courier New]="txtDesignation"><[/FONT][/COLOR][COLOR=maroon][FONT=Courier New]input[/FONT][/COLOR][COLOR=red][FONT=Courier New]name[/FONT][/COLOR][COLOR=blue][FONT=Courier New]="txttxtDesignation" [/FONT][/COLOR][COLOR=red][FONT=Courier New]type[/FONT][/COLOR][COLOR=blue][FONT=Courier New]="text" [/FONT][/COLOR][COLOR=red][FONT=Courier New]value[/FONT][/COLOR][COLOR=blue][FONT=Courier New]="S1" [/FONT][/COLOR][COLOR=red][FONT=Courier New]maxlength[/FONT][/COLOR][COLOR=blue][FONT=Courier New]="50" [/FONT][/COLOR][COLOR=red][FONT=Courier New]readonly[/FONT][/COLOR][COLOR=blue][FONT=Courier New]="readonly" [/FONT][/COLOR][COLOR=red][FONT=Courier New]id[/FONT][/COLOR][COLOR=blue][FONT=Courier New]="txttxtDesignation" /></< font>[/FONT][COLOR=maroon][FONT=Courier New]span[/FONT][/COLOR][COLOR=blue][FONT=Courier New]></< font>[/FONT][COLOR=maroon][FONT=Courier New]td[/FONT][/COLOR][COLOR=blue][FONT=Courier New]><o:p></o:p>[/FONT][/COLOR]
[COLOR=blue][FONT=Courier New]<o:p></o:p>[/FONT][/COLOR]
[FONT=Courier New]<o:p></o:p>[/FONT]
[/COLOR][/COLOR][/COLOR][/COLOR][/COLOR]


Value working
Code:
[COLOR=blue][COLOR=#0000ff][COLOR=#0000ff][COLOR=#0000ff][COLOR=#0000ff][COLOR=#ff0000]id[/COLOR]="serInformal"><[COLOR=#800000]tr[/COLOR]><o:p></o:p>
[FONT=Calibri]<INPUT id=syn_ctrl179 class=SYN_LNN value=179 type=label unselectable="on"> <INPUT id=syn_ctrl179 class=SYN_BCH role=button value=- type=label unselectable="on"> <[/FONT][FONT=Calibri][COLOR=#800000]td[/COLOR][/FONT][FONT=Calibri][COLOR=#ff0000]class[/COLOR][/FONT][FONT=Calibri]=[/FONT][FONT=Calibri]"isg_formLabel"[/FONT][FONT=Calibri][COLOR=#ff0000]style[/COLOR][/FONT][FONT=Calibri]=[/FONT][FONT=Calibri]"width:30%;"[/FONT][FONT=Calibri]><[/FONT][FONT=Calibri][COLOR=#800000]span[/COLOR][/FONT][FONT=Calibri][COLOR=#ff0000]id[/COLOR][/FONT][FONT=Calibri]=[/FONT][FONT=Calibri]"lblInformal"[/FONT][FONT=Calibri]>[/FONT][FONT=Calibri][COLOR=#000000]Nick Name[/COLOR][/FONT][FONT=Calibri]</< font>[FONT=Calibri][COLOR=#800000]span[/COLOR][/FONT][FONT=Calibri]></< font>[FONT=Calibri][COLOR=#800000]td[/COLOR][/FONT][FONT=Calibri]><[/FONT][FONT=Calibri][COLOR=#800000]td[/COLOR][/FONT][FONT=Calibri][COLOR=#ff0000]class[/COLOR][/FONT][FONT=Calibri]=[/FONT][FONT=Calibri]"isg_formData"[/FONT][FONT=Calibri][COLOR=#ff0000]colspan[/COLOR][/FONT][FONT=Calibri]=[/FONT][FONT=Calibri]"1"[/FONT][FONT=Calibri][COLOR=#ff0000]style[/COLOR][/FONT][FONT=Calibri]=[/FONT][FONT=Calibri]"width:70%;"[/FONT][FONT=Calibri]><[/FONT][FONT=Calibri][COLOR=#800000]span[/COLOR][/FONT][FONT=Calibri][COLOR=#ff0000]id[/COLOR][/FONT][FONT=Calibri]=[/FONT][FONT=Calibri]"txtInformal"[/FONT][FONT=Calibri]><[/FONT][FONT=Calibri][COLOR=#800000]input[/COLOR][/FONT][FONT=Calibri][COLOR=#ff0000]name[/COLOR][/FONT][FONT=Calibri]=[/FONT][FONT=Calibri]"txttxtInformal"[/FONT][FONT=Calibri][COLOR=#ff0000]type[/COLOR][/FONT][FONT=Calibri]=[/FONT][FONT=Calibri]"text"[/FONT][FONT=Calibri][COLOR=#ff0000]value[/COLOR][/FONT][FONT=Calibri]=[/FONT][FONT=Calibri]"Maguire S."[/FONT][FONT=Calibri][COLOR=#ff0000]maxlength[/COLOR][/FONT][FONT=Calibri]=[/FONT][FONT=Calibri]"20"[/FONT][FONT=Calibri][COLOR=#ff0000]id[/COLOR][/FONT][FONT=Calibri]=[/FONT][FONT=Calibri]"txttxtInformal"[/FONT][FONT=Calibri] /></< font>[FONT=Calibri][COLOR=#800000]span[/COLOR][/FONT][FONT=Calibri]></< font>[FONT=Calibri][COLOR=#800000]td[/COLOR][/FONT][FONT=Calibri]>[/FONT]
[/FONT][/FONT][/FONT][/FONT][/COLOR][/COLOR][/COLOR][/COLOR][/COLOR]



Thanks in advance for the help.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,214,833
Messages
6,121,864
Members
449,052
Latest member
Fuddy_Duddy

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