Need help on javascript web server for macro automation

cheongchuanhong

New Member
Joined
Jan 13, 2016
Messages
4
Below there is my macro vba code.. How could i manipulate the year and month in my sourcecode..

Code:
Sub UpdateFXRate()
'
' UpdateFXRate Macro
'
Dim YR As Integer
YR = Sheets("FX Table").Range("E2").Value
Dim MTH As Integer
MTH = Sheets("FX Table").Range("G2").Value
Dim CurrentBook As String
CurrentBook = ThisWorkbook.Name


Application.ScreenUpdating = False


Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "treasury.abcdef.com/exchangerates/"
IE.Visible = True


On Error Resume Next
Set Element = IE.document.getElementsById("MainContent_ddlYear")
Element.Item(0).Value = YR


Set Element = IE.document.getElementsById("MainContent_ddlMonth")
Element.Item(0).Value = MTH


IE.Quit
Set IE = Nothing
On Error GoTo 0
Windows("excelgen.csv").Activate
Range("A1:J200").Copy
Windows(CurrentBook).Activate
Range("A5").PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True
Windows("excelgen.csv").Activate
Application.DisplayAlerts = False
ActiveWindow.Close
MsgBox "FX rates updated"


End Sub

HTML:
</ul></li><li><a title="Reports" class="popout level1" href="#" *******="__doPostBack('ctl00$NavigationMenu','Reports')">Reports</a><ul class="level2">
			<li><a title="Currency Details" class="level2" href="ExchangeRatesReportMain.aspx?reportname=CurrencyDetail">Currency Details</a></li><li><a title="Currency Audit" class="level2" href="ExchangeRatesReportMain.aspx?reportname=CurrencyAudit">Currency Audit</a></li>
		</ul></li><li><a title="Help" class="level1" href="help.htm" target="_blank">Help</a></li>
	</ul>
</div><a id="NavigationMenu_SkipLink"></a>   
        </div>


        <div class="main">
            
    <br />
    <link href="~/Styles/styles.css" rel="stylesheet" type="text/css" />
    <div class="rounded-corners">
        <table width="800px">
            <tr>
                <td align=center><font color=#7d6754 size=2><B>Month</b></font></td>
                <td align=center><font color=#7d6754 size=2><B>Year</b></font></td>
                <td align=center><font color=#7d6754 size=2><B>Currency</b></font></td>
                <tr>
                    <td align=center>
                        <select name="ctl00$MainContent$ddlMonth" id="MainContent_ddlMonth" class="ddl" style="color:#7D6754;background-color:#F6F1DB;font-family:Tahoma;width:90%;">
	<option value="1">1</option>
	<option value="2">2</option>
	<option value="3">3</option>
	<option value="4">4</option>
	<option value="5">5</option>
	<option value="6">6</option>
	<option value="7">7</option>
	<option value="8">8</option>
	<option selected="selected" value="9">9</option>
	<option value="10">10</option>
	<option value="11">11</option>
	<option value="12">12</option>


</select>
                    </td>
                    <td align=center>  
                        <select name="ctl00$MainContent$ddlYear" id="MainContent_ddlYear" class="ddl" style="color:#7D6754;background-color:#F6F1DB;font-family:Tahoma;width:90%;">
	<option value="1994">1994</option>
	<option value="1995">1995</option>
	<option value="1996">1996</option>
	<option value="1997">1997</option>
	<option value="1998">1998</option>
	<option value="1999">1999</option>
	<option value="2000">2000</option>
	<option value="2001">2001</option>
	<option value="2002">2002</option>
	<option value="2003">2003</option>
	<option value="2004">2004</option>
	<option value="2005">2005</option>
	<option value="2006">2006</option>
	<option value="2007">2007</option>
	<option value="2008">2008</option>
	<option value="2009">2009</option>
	<option value="2010">2010</option>
	<option value="2011">2011</option>
	<option value="2012">2012</option>
	<option value="2013">2013</option>
	<option value="2014">2014</option>
	<option value="2015">2015</option>
	<option selected="selected" value="2016">2016</option>
	<option value="2017">2017</option>


</select>
 
Last edited by a moderator:

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try:
Code:
Set Element = IE.document.getElementById("MainContent_ddlYear")
Element.Value = YR

Set Element = IE.document.getElementById("MainContent_ddlMonth")
Element.Value = MTH
and delete the On Error Resume Text (what is it for?)
 
Upvote 0

Forum statistics

Threads
1,215,829
Messages
6,127,129
Members
449,361
Latest member
VBquery757

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