Hi all,
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
I have been at this problem for close to a year and finally got some headway but stuck at the last leg. Appreciate that someone can help me with this!
<o></o>
OBJECTIVE OF THE MACRO (BASICALLY INTERNET FORM FILLING)<o></o>
PROBLEMS<o></o>
Will give more elaboration below!<o></o>
<o></o>
<o></o>
ACTUAL WEB LAYOUT<o></o>
<o></o>
<o> </o>
(Fig 1 / Before clicking ‘Edit’ Button)
http://www.host-images.com/u/files/v3nhjikndkdj5zzvysi2_thumb.jpg
<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><v:group id=_x0000_s1026 style="WIDTH: 450pt; HEIGHT: 305.25pt; mso-position-horizontal-relative: char; mso-position-vertical-relative: line" coordsize="10464,7098" coordorigin="2527,3937" editas="canvas"><o:lock aspectratio="t" v:ext="edit"></o:lock><v:shapetype id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" oreferrelative="t" o:spt="75" coordsize="21600,21600"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><vath o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></vath><o:lock aspectratio="t" v:ext="edit"></o:lock></v:shapetype><v:shape id=_x0000_s1027 style="LEFT: 2527px; WIDTH: 10464px; POSITION: absolute; TOP: 3937px; HEIGHT: 7098px" oreferrelative="f" type="#_x0000_t75"><v:fill o:detectmouseclick="t"></v:fill><vath o:connecttype="none" o:extrusionok="t"></vath><o:lock v:ext="edit" text="t"></o:lock></v:shape><v:group id=_x0000_s1028 style="LEFT: 2527px; WIDTH: 10464px; POSITION: absolute; TOP: 4411px; HEIGHT: 6624px" coordsize="5232,3312" coordorigin="336,288"><v:rect id=_x0000_s1029 style="LEFT: 336px; WIDTH: 5232px; POSITION: absolute; TOP: 288px; HEIGHT: 3312px; v-text-anchor: middle" fillcolor="#bbe0e3"></v:rect><v:shapetype id=_x0000_t202 path="m,l,21600r21600,l21600,xe" o:spt="202" coordsize="21600,21600"><v:stroke joinstyle="miter"></v:stroke><vath o:connecttype="rect" gradientshapeok="t"></vath></v:shapetype><v:shape id=_x0000_s1030 style="LEFT: 3840px; WIDTH: 1200px; POSITION: absolute; TOP: 432px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="lime"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">Click here to edit<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1031 style="LEFT: 672px; WIDTH: 1200px; POSITION: absolute; TOP: 1920px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#bbe0e3"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">Branch1<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1032 style="LEFT: 672px; WIDTH: 1200px; POSITION: absolute; TOP: 816px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="yellow"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1033 style="LEFT: 3072px; WIDTH: 1200px; POSITION: absolute; TOP: 816px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="yellow"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1034 style="LEFT: 1872px; WIDTH: 1200px; POSITION: absolute; TOP: 816px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="yellow"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1035 style="LEFT: 1872px; WIDTH: 1200px; POSITION: absolute; TOP: 1056px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="yellow"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1036 style="LEFT: 3072px; WIDTH: 1200px; POSITION: absolute; TOP: 1056px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="yellow"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1037 style="LEFT: 672px; WIDTH: 1200px; POSITION: absolute; TOP: 1056px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="yellow"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1038 style="LEFT: 1872px; WIDTH: 1200px; POSITION: absolute; TOP: 1920px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#bbe0e3"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1039 style="LEFT: 4272px; WIDTH: 1200px; POSITION: absolute; TOP: 1920px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#bbe0e3"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1040 style="LEFT: 3072px; WIDTH: 1200px; POSITION: absolute; TOP: 1920px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#bbe0e3"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1041 style="LEFT: 672px; WIDTH: 1200px; POSITION: absolute; TOP: 2160px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#bbe0e3"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">Branch2<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1042 style="LEFT: 1872px; WIDTH: 1200px; POSITION: absolute; TOP: 2160px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#bbe0e3"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1043 style="LEFT: 4272px; WIDTH: 1200px; POSITION: absolute; TOP: 2160px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#bbe0e3"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1044 style="LEFT: 3072px; WIDTH: 1200px; POSITION: absolute; TOP: 2160px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#bbe0e3"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1045 style="LEFT: 672px; WIDTH: 1200px; POSITION: absolute; TOP: 1680px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#36f"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1046 style="LEFT: 1872px; WIDTH: 1200px; POSITION: absolute; TOP: 1680px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#36f"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1047 style="LEFT: 4272px; WIDTH: 1200px; POSITION: absolute; TOP: 1680px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#36f"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1048 style="LEFT: 3072px; WIDTH: 1200px; POSITION: absolute; TOP: 1680px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#36f"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
</TD></TR></TBODY></TABLE></v:textbox></v:shape></v:group><v:shape id=_x0000_s1049 style="LEFT: 2527px; WIDTH: 10464px; POSITION: absolute; TOP: 3937px; HEIGHT: 608px" type="#_x0000_t202" fillcolor="black" strokeweight="2pt" strokecolor="aqua"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
</TD></TR></TBODY></TABLE></v:textbox></v:shape><?xml:namespace prefix = w ns = "urn:schemas-microsoft-comffice:word" /><w:wrap type="none"></w:wrap><w:anchorlock></w:anchorlock></v:group>
<o> </o>
<o> </o>
(Fig 2 / Click ‘Edit’ Button & Red Arrow)
SECTOR
<o> </o>
<o></o>
<o></o>
(Fig 3 / Key in empty fields & Click ‘Yes’ Button)
<o>
</o>
<o></o>
(Fig 4 / Figures will be populated to main screen à click ‘save’)
<o>
</o>
<o></o>
<o></o>
<o></o>
<o></o><o></o>
THE SPREADSHEET DATA FROM WHICH FIGURES ARE PICKED TO FILL THE EMPTY FIELDS IN THE WEBSITE<o></o>
(Figure 5 / Table in Spreadsheet)
<o></o>
So as I run the macro from the spreadsheet, it will:
(1) open up URL for Sector 1 à work within the webpage for Sector 1
a. click the green ‘Click here to edit’ button
b. click the red arrow to bring out the PopUp box (Red) for Branch1
c. fill in all the empty fields for Branch 1 (the empty fields for ‘Total Revenue’ & ‘Total Cost’)
d. click the green ‘Yes’ button à this will close the PopUp box & upload the figures to the empty fields (as in Fig 4)
e. click the green ‘Click here to save’ button (as in Fig 4)
(2) re-run the macro through a for-loop so that it repeats all the steps above to work on URL for Sector 2
<o></o>
PROBLEMS<o></o>
· Without using sendkeys, I am unable to get the macro to upload the figures into the empty fields à the macro just stops & runs into errors because I do not know how to write to access the hidden input (I think)<o></o>
· Even when using sendkeys, it is very unstable à the macro updates the wrong figures, e.g. Total Revenue = 1 instead of 3 for Branch 1 (inputted the Total Cost instead). Using the above example, I am tabbing 6 times to get to the re<o></o>
· PLEASE HELP WITH THIS!!!!
· I have put in the relevant source code & the existing macro below. Hope someone can advise!
<o></o>
<o></o>
SOURCE CODE OF WEBSITE<o></o>
(For Fig 1 / ‘Edit’ Button)<o></o>
<o></o>
type="button" name=" clickmetoedit " id=" clickmetoedit" class="greenButton" value="Edit in fixed mode" *******="editModule()">
</TD>
</TR>
</TABLE>
<HR class=blue_10B SIZE=1>
</TD>
</TR>
<TR align="left">
<TD>
<TABLE height="100%" cellSpacing=1 cellPadding=1 width="100%"><!-- Module start -->
<TBODY><TR>
<TD colSpan=4>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
(For Fig 3 / To key in revenue and cost values)<o></o>
<o></o>
<o></o>
Branch1
<INPUT class=C55_black_13 id=branchid2 type=hidden value="Branch2_[FONT=Arial>PopupBox<FONT][SIZE=3>][COLOR=name=branch2 black?><FONT face=Arial>PopupBox<FONT face=][/COLOR][/SIZE][/FONT]
</TD>
<TD width="2%">
[FONT=Arial>][SIZE=3>][COLOR=><FONT face=Arial> Popup Box<FONT face=][/COLOR][/FONT]
[/SIZE]</TD>
<!--
<TD id="'Branch2_[FONT=Arial>Popup][SIZE=3>][COLOR=align=right black?><FONT face=Arial>Popup Box<FONT face=][/COLOR][/SIZE][/FONT]
<LABEL class=C55_black_13 id=netrevenue2label>
2
</LABEL>
<INPUT type=hidden name=totalrevenue_2 font <>
id="netrevenue2" class="C55_black_13" value="2">
</TD>
<TD align=right>
<LABEL class=C55_black_13 id=" totalrev2label ">3</LABEL>
<INPUT class=C55_black_13 id=totalrev2 type=hidden value=4 name=total_rev2>
</TD>
<TD align=right>
<LABEL class=C55_black_13 id=totalcostlabel_2>1</LABEL>
<INPUT class=C55_black_13 id=totalcost2 type=hidden value=1 name=totalcost_2>
</TD>
<TD align=right>
<o></o>
<o></o>
<o></o>
<o></o>
MY MACRO <o></o>
Sub FillInternetForms()
<o></o>
Dim Button As HTMLButtonElement
Dim btnInput As MSHTML.HTMLInputElement, LoginBtn As MSHTML.HTMLInputElement
Dim ElementCol As MSHTML.IHTMLElementCollection
Dim Link As MSHTML.HTMLAnchorElement
Dim Done As Long, Nm As Long
<o></o>
Dim r As Integer
r = 2
<o></o>
Dim url As String
<o></o>
Application.ScreenUpdating = False
Nm = 1234
<o></o>
Set appIE = New InternetExplorer
<o></o>
For r = 2 To 5
url = Cells(1, 5).Value & Cells(r, 1).Value
<o></o>
<o></o>
With appIE
.navigate url
.Visible = True
End With
<o></o>
<o></o>
' ================= click the edit button ==============================
Do While appIE.Busy Or appIE.readyState <> READYSTATE_COMPLETE
DoEvents
<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-comffice:smarttags" /><st1lace w:st="on">Loop</st1lace>
<o></o>
Done = 0: i = 1
On Error Resume Next
Do While Done <> 1 Or Err.Number <> 0
Done = 0
Set ElementCol = appIE.Document.getElementsByTagName("Input")
For Each btnInput In ElementCol
If btnInput.Name = "clickmetoedit" Then
Done = Done + 1
btnInput.Click
End If
Next btnInput
<st1lace w:st="on">Loop</st1lace>
On Error GoTo 0
<o></o>
Do While appIE.Busy Or appIE.readyState <> READYSTATE_COMPLETE
DoEvents
<st1lace w:st="on">Loop</st1lace>
<o></o>
' ================= click the arrow image to bring up the Pop-up Box ===========
Done = 0: i = 1
On Error Resume Next
Do While Done <> 1 Or Err.Number <> 0
Done = 0
Set ElementCol = appIE.Document.getElementsByTagName("img")
For Each btnInput In ElementCol
If InStr(1, btnInput.getAttribute("*******"), Cells(r, 5).Value) Then
Done = Done + 1
btnInput.Click
End If
i = i + 1
Next btnInput
<st1lace w:st="on">Loop</st1lace>
<o></o>
<o></o>
' ================= click the arrow image to bring out the Pop-Up Box =========
For i = 1 To 42 + Cells(r, 6).Value
SendKeys "{Tab}", True
Application.Wait Now + TimeValue("00:00:01")
Next i
<o></o>
<o></o>
<o></o>
' ================= USE SENDKEYS TO UPLOAD THE FIGURES ========
<o></o>
<o></o>
'=========copy figure from cell B2 of the excel sheet into ‘Total Revenue’ field =======
Application.Wait Now + TimeValue("00:00:03")
SendKeys CStr(Worksheets(1).Cells(r, 2).Value), True
Application.Wait Now + TimeValue("00:00:03")
<o></o>
'=========copy figure from cell B2 of the excel sheet into ‘Total Cost’ field ========
'SendKeys "{Tab}", True
'Application.Wait Now + TimeValue("00:00:03")
'SendKeys CStr(Worksheets(1).Cells(r, 3).Value), True
'Application.Wait Now + TimeValue("00:00:03")
<o></o>
<o></o>
<o></o>
Do While appIE.Busy Or appIE.readyState <> READYSTATE_COMPLETE
DoEvents
<st1lace w:st="on">Loop</st1lace>
<o></o>
<o></o>
<o></o>
' =========== click the confirm button ===================
<o></o>
Set ElementCol = appIE.Document.getElementsByTagName("Input")
For Each btnInput In ElementCol
If btnInput.Name = "clickmetoconfirm" Then
Done = Done + 1
btnInput.Click
End If
Next btnInput
<o></o>
<o></o>
<o></o>
' =============== click the savebutton =============
Set ElementCol = appIE.Document.getElementsByTagName("Input")
For Each btnInput In ElementCol
If btnInput.Name = "clickmetosave" Then
Done = Done + 1
btnInput.Click
End If
Next btnInput
Application.Wait Now + TimeValue("00:00:01")
<o></o>
Next r
End Sub
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
</TR>
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
I have been at this problem for close to a year and finally got some headway but stuck at the last leg. Appreciate that someone can help me with this!
<o></o>
OBJECTIVE OF THE MACRO (BASICALLY INTERNET FORM FILLING)<o></o>
- Open up multiple websites through the multiple weblinks recorded in a spreadsheet<o></o>
- Click the relevant buttons & copy some numerical figures from the spreadsheet into the websites, then click on the submit button in the websites to upload the figures<o></o>
PROBLEMS<o></o>
- Unable to write the macro to upload figures from the spreadsheet<o></o>
- The fields to fill belong to ‘hidden input’ type<o></o>
- Unable to access it like what was done for clicking edit button & submit button<o></o>
- Currently used an alternative à use ‘sendkeys method’ to (1) tab through the other fields in the website, (2) copy figures from the spreadsheet, (3) paste into the empty field which was tabbed to<o></o>
- However, sendkeys are very unstable & sometimes tab to the wrong field!<o></o>
Will give more elaboration below!<o></o>
<o></o>
<o></o>
ACTUAL WEB LAYOUT<o></o>
<o></o>
<o> </o>
(Fig 1 / Before clicking ‘Edit’ Button)
http://www.host-images.com/u/files/v3nhjikndkdj5zzvysi2_thumb.jpg
<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><v:group id=_x0000_s1026 style="WIDTH: 450pt; HEIGHT: 305.25pt; mso-position-horizontal-relative: char; mso-position-vertical-relative: line" coordsize="10464,7098" coordorigin="2527,3937" editas="canvas"><o:lock aspectratio="t" v:ext="edit"></o:lock><v:shapetype id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" oreferrelative="t" o:spt="75" coordsize="21600,21600"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><vath o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></vath><o:lock aspectratio="t" v:ext="edit"></o:lock></v:shapetype><v:shape id=_x0000_s1027 style="LEFT: 2527px; WIDTH: 10464px; POSITION: absolute; TOP: 3937px; HEIGHT: 7098px" oreferrelative="f" type="#_x0000_t75"><v:fill o:detectmouseclick="t"></v:fill><vath o:connecttype="none" o:extrusionok="t"></vath><o:lock v:ext="edit" text="t"></o:lock></v:shape><v:group id=_x0000_s1028 style="LEFT: 2527px; WIDTH: 10464px; POSITION: absolute; TOP: 4411px; HEIGHT: 6624px" coordsize="5232,3312" coordorigin="336,288"><v:rect id=_x0000_s1029 style="LEFT: 336px; WIDTH: 5232px; POSITION: absolute; TOP: 288px; HEIGHT: 3312px; v-text-anchor: middle" fillcolor="#bbe0e3"></v:rect><v:shapetype id=_x0000_t202 path="m,l,21600r21600,l21600,xe" o:spt="202" coordsize="21600,21600"><v:stroke joinstyle="miter"></v:stroke><vath o:connecttype="rect" gradientshapeok="t"></vath></v:shapetype><v:shape id=_x0000_s1030 style="LEFT: 3840px; WIDTH: 1200px; POSITION: absolute; TOP: 432px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="lime"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">Click here to edit<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1031 style="LEFT: 672px; WIDTH: 1200px; POSITION: absolute; TOP: 1920px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#bbe0e3"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">Branch1<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1032 style="LEFT: 672px; WIDTH: 1200px; POSITION: absolute; TOP: 816px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="yellow"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
Field 1<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1033 style="LEFT: 3072px; WIDTH: 1200px; POSITION: absolute; TOP: 816px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="yellow"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
Field 3<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1034 style="LEFT: 1872px; WIDTH: 1200px; POSITION: absolute; TOP: 816px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="yellow"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
Field 2<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1035 style="LEFT: 1872px; WIDTH: 1200px; POSITION: absolute; TOP: 1056px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="yellow"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
Field 5<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1036 style="LEFT: 3072px; WIDTH: 1200px; POSITION: absolute; TOP: 1056px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="yellow"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
Field 6<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1037 style="LEFT: 672px; WIDTH: 1200px; POSITION: absolute; TOP: 1056px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="yellow"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
Field 4<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1038 style="LEFT: 1872px; WIDTH: 1200px; POSITION: absolute; TOP: 1920px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#bbe0e3"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
3<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1039 style="LEFT: 4272px; WIDTH: 1200px; POSITION: absolute; TOP: 1920px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#bbe0e3"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
2<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1040 style="LEFT: 3072px; WIDTH: 1200px; POSITION: absolute; TOP: 1920px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#bbe0e3"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
1<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1041 style="LEFT: 672px; WIDTH: 1200px; POSITION: absolute; TOP: 2160px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#bbe0e3"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">Branch2<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1042 style="LEFT: 1872px; WIDTH: 1200px; POSITION: absolute; TOP: 2160px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#bbe0e3"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
<o> </o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1043 style="LEFT: 4272px; WIDTH: 1200px; POSITION: absolute; TOP: 2160px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#bbe0e3"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
<o> </o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1044 style="LEFT: 3072px; WIDTH: 1200px; POSITION: absolute; TOP: 2160px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#bbe0e3"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
<o> </o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1045 style="LEFT: 672px; WIDTH: 1200px; POSITION: absolute; TOP: 1680px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#36f"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
Branch No<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1046 style="LEFT: 1872px; WIDTH: 1200px; POSITION: absolute; TOP: 1680px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#36f"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
Total Revenue<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1047 style="LEFT: 4272px; WIDTH: 1200px; POSITION: absolute; TOP: 1680px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#36f"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
Net Revenue<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><v:shape id=_x0000_s1048 style="LEFT: 3072px; WIDTH: 1200px; POSITION: absolute; TOP: 1680px; HEIGHT: 237px" type="#_x0000_t202" fillcolor="#36f"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
Total Cost<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape></v:group><v:shape id=_x0000_s1049 style="LEFT: 2527px; WIDTH: 10464px; POSITION: absolute; TOP: 3937px; HEIGHT: 608px" type="#_x0000_t202" fillcolor="black" strokeweight="2pt" strokecolor="aqua"><v:textbox inset="1.75261mm,.87631mm,1.75261mm,.87631mm"><TABLE cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BORDER-RIGHT: #e0dfe3; BORDER-TOP: #e0dfe3; BORDER-LEFT: #e0dfe3; BORDER-BOTTOM: #e0dfe3; BACKGROUND-COLOR: transparent">
SECTOR 1<o></o>
</TD></TR></TBODY></TABLE></v:textbox></v:shape><?xml:namespace prefix = w ns = "urn:schemas-microsoft-comffice:word" /><w:wrap type="none"></w:wrap><w:anchorlock></w:anchorlock></v:group>
<o> </o>
<o> </o>
(Fig 2 / Click ‘Edit’ Button & Red Arrow)
SECTOR
<o> </o>
<o></o>
<o></o>
(Fig 3 / Key in empty fields & Click ‘Yes’ Button)
<o>
<o></o>
(Fig 4 / Figures will be populated to main screen à click ‘save’)
<o>
<o></o>
<o></o>
<o></o>
<o></o><o></o>
THE SPREADSHEET DATA FROM WHICH FIGURES ARE PICKED TO FILL THE EMPTY FIELDS IN THE WEBSITE<o></o>
(Figure 5 / Table in Spreadsheet)
<o></o>
<TABLE class=MsoNormalTable style="MARGIN: auto auto auto -64.5pt; WIDTH: 573.9pt; BORDER-COLLAPSE: collapse; mso-padding-alt: 0in 5.4pt 0in 5.4pt" cellSpacing=0 cellPadding=0 width=765 border=0><TBODY><TR style="HEIGHT: 12.75pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes"><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: silver; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 21pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; mso-border-alt: solid windowtext .5pt" vAlign=bottom noWrap width=28>
</TD></TR></TBODY></TABLE><o></o>
<o></o><o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: silver; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 93.9pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; mso-border-top-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom noWrap width=125>
A<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: silver; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 54.1pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; mso-border-top-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom noWrap width=72>
B<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: silver; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 50pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; mso-border-top-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom noWrap width=67>
C<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: silver; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 282.9pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; mso-border-top-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom noWrap width=377>
D<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: silver; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 1in; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; mso-border-top-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom noWrap width=96>
E<o></o>
</TD></TR><TR style="HEIGHT: 38.25pt; mso-yfti-irow: 1"><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; BACKGROUND: silver; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 21pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 38.25pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" width=28>
1<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; BACKGROUND: #ccffff; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 93.9pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 38.25pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" width=125>
URLs of different sectors<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; BACKGROUND: #ccffff; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 54.1pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 38.25pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" width=72>
Total Revenue<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; BACKGROUND: #ccffff; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 50pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 38.25pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" width=67>
Total Cost<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; BACKGROUND: #ccffff; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 282.9pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 38.25pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" width=377>
The identifier in the source code for each Branch No Dropdown Box<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; BACKGROUND: #ccffff; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 1in; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 38.25pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" width=96>
How many of the same Branch No<o></o>
</TD></TR><TR style="HEIGHT: 12.75pt; mso-yfti-irow: 2"><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; BACKGROUND: silver; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 21pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=bottom noWrap width=28>
2<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 93.9pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" width=125>
URL for Sector 1<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 54.1pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom noWrap width=72>
3<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 50pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom noWrap width=67>
1<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 282.9pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom noWrap width=377>
SourceCode Identifier for Sector 1 / Branch 1 Popup Box<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 1in; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom noWrap width=96>
2<o></o>
</TD></TR><TR style="HEIGHT: 12.75pt; mso-yfti-irow: 3"><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; BACKGROUND: silver; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 21pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=bottom noWrap width=28>
3<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 93.9pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" width=125>
URL for Sector 2<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 54.1pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom noWrap width=72>
5<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 50pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom noWrap width=67>
1<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 282.9pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom noWrap width=377>
SourceCode Identifier for Sector 1 / Branch 2 Popup Box<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 1in; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom noWrap width=96>
1<o></o>
</TD></TR><TR style="HEIGHT: 12.75pt; mso-yfti-irow: 4; mso-yfti-lastrow: yes"><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; BACKGROUND: silver; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 21pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=bottom noWrap width=28>
4<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 93.9pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" width=125>
URL for Sector 3<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 54.1pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom noWrap width=72>
4<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 50pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom noWrap width=67>
1<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 282.9pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom noWrap width=377>
SourceCode Identifier for Sector 1 / Branch 3 Popup Box<o></o>
</TD><TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #e0dfe3; WIDTH: 1in; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" vAlign=bottom noWrap width=96>
2<o></o>
</TD></TR></TBODY></TABLE><o></o>
So as I run the macro from the spreadsheet, it will:
(1) open up URL for Sector 1 à work within the webpage for Sector 1
a. click the green ‘Click here to edit’ button
b. click the red arrow to bring out the PopUp box (Red) for Branch1
c. fill in all the empty fields for Branch 1 (the empty fields for ‘Total Revenue’ & ‘Total Cost’)
d. click the green ‘Yes’ button à this will close the PopUp box & upload the figures to the empty fields (as in Fig 4)
e. click the green ‘Click here to save’ button (as in Fig 4)
(2) re-run the macro through a for-loop so that it repeats all the steps above to work on URL for Sector 2
<o></o>
PROBLEMS<o></o>
· Without using sendkeys, I am unable to get the macro to upload the figures into the empty fields à the macro just stops & runs into errors because I do not know how to write to access the hidden input (I think)<o></o>
· Even when using sendkeys, it is very unstable à the macro updates the wrong figures, e.g. Total Revenue = 1 instead of 3 for Branch 1 (inputted the Total Cost instead). Using the above example, I am tabbing 6 times to get to the re<o></o>
· PLEASE HELP WITH THIS!!!!
· I have put in the relevant source code & the existing macro below. Hope someone can advise!
<o></o>
<o></o>
SOURCE CODE OF WEBSITE<o></o>
(For Fig 1 / ‘Edit’ Button)<o></o>
<o></o>
type="button" name=" clickmetoedit " id=" clickmetoedit" class="greenButton" value="Edit in fixed mode" *******="editModule()">
</TD>
</TR>
</TABLE>
<HR class=blue_10B SIZE=1>
</TD>
</TR>
<TR align="left">
<TD>
<TABLE height="100%" cellSpacing=1 cellPadding=1 width="100%"><!-- Module start -->
<TBODY><TR>
<TD colSpan=4>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
(For Fig 3 / To key in revenue and cost values)<o></o>
<o></o>
<o></o>
Branch1
<INPUT class=C55_black_13 id=branchid2 type=hidden value="Branch2_[FONT=Arial>PopupBox<FONT][SIZE=3>][COLOR=name=branch2 black?><FONT face=Arial>PopupBox<FONT face=][/COLOR][/SIZE][/FONT]
</TD>
<TD width="2%">
[/SIZE]</TD>
<!--
<TD id="'Branch2_[FONT=Arial>Popup][SIZE=3>][COLOR=align=right black?><FONT face=Arial>Popup Box<FONT face=][/COLOR][/SIZE][/FONT]
<LABEL class=C55_black_13 id=netrevenue2label>
2
</LABEL>
<INPUT type=hidden name=totalrevenue_2 font <>
id="netrevenue2" class="C55_black_13" value="2">
</TD>
<TD align=right>
<LABEL class=C55_black_13 id=" totalrev2label ">3</LABEL>
<INPUT class=C55_black_13 id=totalrev2 type=hidden value=4 name=total_rev2>
</TD>
<TD align=right>
<LABEL class=C55_black_13 id=totalcostlabel_2>1</LABEL>
<INPUT class=C55_black_13 id=totalcost2 type=hidden value=1 name=totalcost_2>
</TD>
<TD align=right>
<o></o>
<o></o>
<o></o>
<o></o>
MY MACRO <o></o>
Sub FillInternetForms()
<o></o>
Dim Button As HTMLButtonElement
Dim btnInput As MSHTML.HTMLInputElement, LoginBtn As MSHTML.HTMLInputElement
Dim ElementCol As MSHTML.IHTMLElementCollection
Dim Link As MSHTML.HTMLAnchorElement
Dim Done As Long, Nm As Long
<o></o>
Dim r As Integer
r = 2
<o></o>
Dim url As String
<o></o>
Application.ScreenUpdating = False
Nm = 1234
<o></o>
Set appIE = New InternetExplorer
<o></o>
For r = 2 To 5
url = Cells(1, 5).Value & Cells(r, 1).Value
<o></o>
<o></o>
With appIE
.navigate url
.Visible = True
End With
<o></o>
<o></o>
' ================= click the edit button ==============================
Do While appIE.Busy Or appIE.readyState <> READYSTATE_COMPLETE
DoEvents
<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-comffice:smarttags" /><st1lace w:st="on">Loop</st1lace>
<o></o>
Done = 0: i = 1
On Error Resume Next
Do While Done <> 1 Or Err.Number <> 0
Done = 0
Set ElementCol = appIE.Document.getElementsByTagName("Input")
For Each btnInput In ElementCol
If btnInput.Name = "clickmetoedit" Then
Done = Done + 1
btnInput.Click
End If
Next btnInput
<st1lace w:st="on">Loop</st1lace>
On Error GoTo 0
<o></o>
Do While appIE.Busy Or appIE.readyState <> READYSTATE_COMPLETE
DoEvents
<st1lace w:st="on">Loop</st1lace>
<o></o>
' ================= click the arrow image to bring up the Pop-up Box ===========
Done = 0: i = 1
On Error Resume Next
Do While Done <> 1 Or Err.Number <> 0
Done = 0
Set ElementCol = appIE.Document.getElementsByTagName("img")
For Each btnInput In ElementCol
If InStr(1, btnInput.getAttribute("*******"), Cells(r, 5).Value) Then
Done = Done + 1
btnInput.Click
End If
i = i + 1
Next btnInput
<st1lace w:st="on">Loop</st1lace>
<o></o>
<o></o>
' ================= click the arrow image to bring out the Pop-Up Box =========
For i = 1 To 42 + Cells(r, 6).Value
SendKeys "{Tab}", True
Application.Wait Now + TimeValue("00:00:01")
Next i
<o></o>
<o></o>
<o></o>
' ================= USE SENDKEYS TO UPLOAD THE FIGURES ========
<o></o>
<o></o>
'=========copy figure from cell B2 of the excel sheet into ‘Total Revenue’ field =======
Application.Wait Now + TimeValue("00:00:03")
SendKeys CStr(Worksheets(1).Cells(r, 2).Value), True
Application.Wait Now + TimeValue("00:00:03")
<o></o>
'=========copy figure from cell B2 of the excel sheet into ‘Total Cost’ field ========
'SendKeys "{Tab}", True
'Application.Wait Now + TimeValue("00:00:03")
'SendKeys CStr(Worksheets(1).Cells(r, 3).Value), True
'Application.Wait Now + TimeValue("00:00:03")
<o></o>
<o></o>
<o></o>
Do While appIE.Busy Or appIE.readyState <> READYSTATE_COMPLETE
DoEvents
<st1lace w:st="on">Loop</st1lace>
<o></o>
<o></o>
<o></o>
' =========== click the confirm button ===================
<o></o>
Set ElementCol = appIE.Document.getElementsByTagName("Input")
For Each btnInput In ElementCol
If btnInput.Name = "clickmetoconfirm" Then
Done = Done + 1
btnInput.Click
End If
Next btnInput
<o></o>
<o></o>
<o></o>
' =============== click the savebutton =============
Set ElementCol = appIE.Document.getElementsByTagName("Input")
For Each btnInput In ElementCol
If btnInput.Name = "clickmetosave" Then
Done = Done + 1
btnInput.Click
End If
Next btnInput
Application.Wait Now + TimeValue("00:00:01")
<o></o>
Next r
End Sub
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
</TR>
Last edited: