Solved

Excel string to website textarea and submit

Posted on 2011-09-06
13
601 Views
Last Modified: 2012-05-12
I need to send a string from excel cell to website textarea and sudmit form

Page source for textarea
 
<textarea cols="52" style="WIDTH: 440px; HEIGHT: 118px" onchange="BvUpdateLineCount()" class="codeInputBatch" wrap="off" rows="7" name="text" id="BvTextArea"></textarea>

Open in new window


Page Source for Submit
 
<a href="javascript:void(0)" onclick="top.frames['LoginFrame'].ValidateBetSubmit("Please log in and select \"Submit Batch\" again to place your bet.","BvSubmitBatchClicked('/ExpressBet/Upload/SubmitBatch.aspx?State=2','BetTicket','640','530');");">SUBMIT BATCH</a>

Open in new window


Page Source
tr id="BvMainContent">
<td class="lightBlue" align="left" valign="top" style="WIDTH: 453px" colspan="2">
<textarea id="BvTextArea" class="codeInputBatch" cols="52" style="WIDTH: 440px; HEIGHT: 118px" onchange="BvUpdateLineCount()" wrap="off" rows="7" name="text"></textarea>
</td>
<td class="lightBlue" align="right" valign="top">
<table cellspacing="2" cellpadding="0" border="0">
<tbody>
<tr>
<td class="ButtonGrey">
<td>&nbsp;</td>
<td class="ButtonBlue">
<a href="javascript:void(0)" onclick="top.frames['LoginFrame'].ValidateBetSubmit("Please log in and select \"Submit Batch\" again to place your bet.","BvSubmitBatchClicked('/ExpressBet/Upload/SubmitBatch.aspx?State=2','BetTicket','640','530');");">SUBMIT BATCH</a>
</td>
</tr>
<tr>
<tr>
</tbody>
</table>
</td>
</tr>

Open in new window


Needs to be in a VS module function to be run by timer at a specified time

Can anyone help
0
Comment
Question by:Jason
  • 8
  • 4
13 Comments
 
LVL 19

Expert Comment

by:akoster
ID: 36495185
It can be done using VBA code in an excel document, but this approach will not use a visual studio module.
When you want me to help you out in this direction, please let me know.
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 36498055
@akoster, there is a related question here: http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_27292458.html

@Renegade_AD: sorry I've been busy on other things, I think I missed the other one but this is an interesting one as well. So the main difference is the absense of a submit button I think. The textarea has an id so should be easy to retrieve but the anchor with href must be looked up in a different manner. I'm assuming in reality it is not the only <a> tag on the page ;)

So, the first thing that remains a problem for me is that I don't have a full version of Visual Studio and no option to create an "Excel Workbook project". Also of course without an account I can't really test the other screens after the login, other than based on the page source you provide.

That being said, I still want to put some first little steps and see how far we get.

If this new code is being run in a Timer event handler, I wonder if it will work when we create a new "objIE", or maybe you have already made that a global variable?

The code for this part should be something like this:

Dim objIE
Set objIE = WScript.CreateObject("InternetExplorer.Application")
objIE.Navigate "http://www.schutt.nl/ee/Q_27294498/testpage.htm"
objIE.Visible = true
While objIE.Busy = true
	WScript.Sleep 100
Wend
objIE.Document.all.BvTextArea.InnerText = "test value for textarea"
Dim a
For Each a In objIE.document.GetElementsByTagName("A")
	If a.innerText = "SUBMIT BATCH" Then
		a.Click
		Exit For
	End If
Next

Open in new window

0
 

Author Comment

by:Jason
ID: 36499799
Hi Robert

Ran the code something strange happened

the first time errors as in img. the second time went through
every other time since errors as in img

Very confusing maybe you understand

I attached this new code to the bottom of the previous one as it is all one function.
once we get this sorted and submits then its just a matter of logging off and closing explorer

 Error
0
 

Author Comment

by:Jason
ID: 36499850
Thought this may also help

 site img
0
 

Author Comment

by:Jason
ID: 36499871
Also got this with anchors and element information
Hope this helps

Element and anchor info
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 36500611
Weird. Well the 2nd and 3rd screenshot seem perfectly fine to me. In this situation the code should work.

It looks like the page is not always loading correctly maybe because the login session expired? Or there could be something going on with the frames. I see in the Submit code that the Login frame is referenced, so maybe we should be using objIE.document.frames... to reference the textarea and anchor as well. Can you examine the page source and possibly frame source(s) right after login and see how it is structured?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Jason
ID: 36515266
Hi Robert

Took a look it appears there is a form within a form

The first for is as you thought was at the start and the second on in set in an iframe

Page source

 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" style="height:100%;">
	<head><meta name="keywords" content="bet, betting, punt, punter, wagering, online gambling, horse racing, Melbourne Cup, greyhound, harness, galloping, trifecta, quinella, exacta, first 4, flexi, fixed odds, totalizator, secure, account, tote" /><meta name="description" content="Australia's premier racing betting site. Government approved and secure so you can bet on horse racing, harness racing and greyhound racing with confidence." /><link href="/Shared/Styles/sty_express.css?v=5.14.2.0" rel="stylesheet" type="text/css" /><title>
	TAB Sportsbet - Horse Racing - Greyhound Racing - Harness Racing
</title></head>
	<body class="betScreen" style="height:100%;" >
		<form name="Form1" method="post" action="Default.aspx?State=2" id="Form1" style="height:100%;">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2Njg3MTA0MTgPZBYEAgQPZBYCAgUPZBYCAgEPFCsAAhAPZBYCHghvbmNoYW5nZQUUTnRnRGRsQ2hhbmdlZCh0aGlzKTsQFQ8KTmV4dCBUbyBHbw8mbmJzcDsmbmJzcDtBbGwRJm5ic3A7Jm5ic3A7UmFjZXMTJm5ic3A7Jm5ic3A7SGFybmVzcxYmbmJzcDsmbmJzcDtHcmV5aG91bmRzCE1lZXRpbmdzDyZuYnNwOyZuYnNwO0FsbBEmbmJzcDsmbmJzcDtSYWNlcxMmbmJzcDsmbmJzcDtIYXJuZXNzFiZuYnNwOyZuYnNwO0dyZXlob3VuZHMIUHJlc2FsZXMPJm5ic3A7Jm5ic3A7QWxsESZuYnNwOyZuYnNwO1JhY2VzEyZuYnNwOyZuYnNwO0hhcm5lc3MWJm5ic3A7Jm5ic3A7R3JleWhvdW5kcxUPAAdOVEd8QUxMDU5UR3xHYWxsb3BpbmcLTlRHfEhhcm5lc3MOTlRHfEdyZXlob3VuZHMAB01UR3xBTEwNTVRHfEdhbGxvcGluZwtNVEd8SGFybmVzcw5NVEd8R3JleWhvdW5kcwAHUFJFfEFMTA1QUkV8R2FsbG9waW5nC1BSRXxIYXJuZXNzDlBSRXxHcmV5aG91bmRzFCsDD2dnZ2dnZ2dnZ2dnZ2dnZxYBZmRkAgYPFgIeBFRleHQFkwE8c2NyaXB0IHR5cGU9J3RleHQvamF2YXNjcmlwdCc+TnRnQ2hhbmdlUmFjZSgnUicsJ0wnLCcyMDExLTA5LTEwVDAwOjAwOjAwJywnMDUnLGRvY3VtZW50LmdldEVsZW1lbnRCeUlkKCcyMDExLTA5LTEwVDAwOjAwOjAwUkwwNV9MaW5rMicpKTs8L3NjcmlwdD5kZBfbYPGApQ16fTbaSO0KFe4LEjpn" />
</div>


<script src="/Shared/Scripts/Shared/GlobalCompiled.js?v=5.14.2.0" type="text/javascript"></script>

<script src="/Shared/Scripts/Shared/DeepMetrixCompiled.js?v=5.14.2.0" type="text/javascript"></script>
<script src="/Shared/Scripts/ExpressBet/UtilityCompiled.js?v=5.14.2.0" type="text/javascript"></script>
<script src="/Shared/Scripts/expressbet/XmlHttpCompiled.js?v=5.14.2.0" type="text/javascript"></script>
<script src="/Shared/Scripts/ExpressBet/XmlHttpControlsCompiled.js?v=5.14.2.0" type="text/javascript"></script>
<script src="/Shared/Scripts/expressbet/PageManagerCompiled.js?v=5.14.2.0" type="text/javascript"></script>
<script src="/Shared/Scripts/expressbet/StandardModeCompiled.js?v=5.14.2.0" type="text/javascript"></script>
<script src="/Shared/Scripts/expressbet/BetCompiled.js?v=5.14.2.0" type="text/javascript"></script>
<script src="/Shared/Scripts/expressbet/BatchViewerCompiled.js?v=5.14.2.0" type="text/javascript"></script>
<script src="/Shared/Scripts/expressbet/BetRulesCompiled.js?v=5.14.2.0" type="text/javascript"></script>

<script src="/Shared/Scripts/ExpressBet/BetAmountHeaderCompiled.js?v=5.14.2.0" type="text/javascript"></script>
<script src="/Shared/Scripts/Shared/DisplayAccountBalanceCompiled.js?v=5.14.2.0" type="text/javascript"></script>
<script src="/Shared/Scripts/Shared/CookieCompiled.js?v=5.14.2.0" type="text/javascript"></script>
<script src="/Shared/Scripts/expressbet/CookieCallbackCompiled.js?v=5.14.2.0" type="text/javascript"></script>
<script src="/Shared/Scripts/expressbet/ParlayFormulaCompiled.js?v=5.14.2.0" type="text/javascript"></script>
<script src="/Shared/Scripts/Betting/StandardBetsCompiled.js?v=5.14.2.0" type="text/javascript"></script>
<script src="/Shared/Scripts/ExpressBet/NextToGoCompiled.js?v=5.14.2.0" type="text/javascript"></script>
<script src="/Shared/Scripts/expressbet/I18NCompiled.js?v=5.14.2.0" type="text/javascript"></script>
		    <input type="hidden" id="cacheSortInfo">

			
			
			<table style="width:100%" border="0" cellpadding="0" cellspacing="0">
				<tr>
					<td colspan="2" style="width:100%;height:100%;">
					    <table border="0" cellpadding="0" cellspacing="0" style="width:100%;min-height:100%;height:100%;">
							<tr>
								<td colspan="2" valign="top" style="height:57px">
									<div id="DIV_PAGE_HEADER">
										<iframe frameborder="0" width="100%" height="57px" src="../LoginFrame.aspx?ExpressBetMode=Standard" scrolling="no" id="LoginFrame" name="LoginFrame"></iframe>

									</div>
								</td>
							</tr>
							<tr>
								<td width="160" align="left" id="leftCol" valign="top">
									

<div id="DIV_NTG">
<input type="hidden" id="cacheNtgSelected" />
<select name="NextToGo1$NextToGoDdl1" id="NextToGo1_NextToGoDdl1" class="sideSelect" onchange="NtgDdlChanged(this);">
	<option selected="selected" value="">Next To Go</option><option value="NTG|ALL">&nbsp;&nbsp;All</option><option value="NTG|Galloping">&nbsp;&nbsp;Races</option><option value="NTG|Harness">&nbsp;&nbsp;Harness</option><option value="NTG|Greyhounds">&nbsp;&nbsp;Greyhounds</option><option value="">Meetings</option><option value="MTG|ALL">&nbsp;&nbsp;All</option><option value="MTG|Galloping">&nbsp;&nbsp;Races</option><option value="MTG|Harness">&nbsp;&nbsp;Harness</option><option value="MTG|Greyhounds">&nbsp;&nbsp;Greyhounds</option><option value="">Presales</option><option value="PRE|ALL">&nbsp;&nbsp;All</option><option value="PRE|Galloping">&nbsp;&nbsp;Races</option><option value="PRE|Harness">&nbsp;&nbsp;Harness</option><option value="PRE|Greyhounds">&nbsp;&nbsp;Greyhounds</option>

</select>
	<div align="right" id="refresh" class="padTop padBottom">
		<b><a href="javascript:void(0);" onclick="NtgRefresh();">REFRESH</a></b>
	</div>
	<div id="DivNtgHtml"></div>
	<div style="display:none">
		<div id="DIV_NTG_NTG_VIEW">
			<b>script</b><script type='text/javascript'>
//reparse=true;
NtgShowNtgView('Sat 10 Sep 2011',
new Array('R|L|2011-09-10T00:00:00|05|14:55|GOLD COAST|Galloping',
'R|M|2011-09-10T00:00:00|06|15:00|MOONEE VALLEY|Galloping',
'R|P|2011-09-10T00:00:00|05|15:05|KEMBLA GRANGE|Galloping',
'R|B|2011-09-10T00:00:00|05|15:10|DOOMBEN|Galloping',
'R|C|2011-09-10T00:00:00|05|15:15|SALE|Galloping',
'H|Y|2011-09-10T00:00:00|10|15:16|AWAPUNI|Galloping',
'R|S|2011-09-10T00:00:00|05|15:20|ROSEHILL|Galloping',
'R|W|2011-09-10T00:00:00|02|15:25|BELMONT|Galloping',
'R|A|2011-09-10T00:00:00|05|15:30|MORPHETTVILLE|Galloping',
'R|L|2011-09-10T00:00:00|06|15:35|GOLD COAST|Galloping',
'R|M|2011-09-10T00:00:00|07|15:40|MOONEE VALLEY|Galloping',
'R|P|2011-09-10T00:00:00|06|15:45|KEMBLA GRANGE|Galloping',
'R|B|2011-09-10T00:00:00|06|15:50|DOOMBEN|Galloping',
'R|C|2011-09-10T00:00:00|06|15:55|SALE|Galloping',
'R|S|2011-09-10T00:00:00|06|16:00|ROSEHILL|Galloping'));</script>					
		</div>

		<div id="DIV_NTG_MTG_VIEW"></div>
		<div id="DIV_NTG_RACES_VIEW"></div>
		<div id="DIV_NTG_BET_TYPE"></div>
	</div>
</div>
								</td>
								<td width="99%" align="left" id="mainContent" valign="top">
									<div id="DIV_STD_MAIN" >
									</div>

								</td>
							</tr>
							<tr>
								<td width="160" align="left" valign="bottom" >
									&nbsp;
								</td>								
								<td width="99%" align="left" valign="bottom">
								    <table cellspacing="0" cellpadding="0" width="100%" border="0">
<tr>
<td class="Footer FooterRightBorder">

<a class="FooterLinkDefault" onmouseover="this.className='FooterLinkMouseOver';" onmouseout="this.className='FooterLinkDefault';" href="http://www.tabaffiliates.com/ProgramDetails.asp" target="_blank">TAB Affiliates</a>&nbsp;|&nbsp;<a class="FooterLinkDefault" onmouseover="this.className='FooterLinkMouseOver';" onmouseout="this.className='FooterLinkDefault';" href="http://nettab.custhelp.com/cgi-bin/nettab.cfg/php/enduser/std_adp.php?p_sid=E*7UQveg&amp;p_lva=128&amp;p_faqid=71" target="_blank">Responsible Gambling</a>&nbsp;|&nbsp;<a class="FooterLinkDefault" onmouseover="this.className='FooterLinkMouseOver';" onmouseout="this.className='FooterLinkDefault';" href="http://nettab.custhelp.com/cgi-bin/nettab.cfg/php/enduser/std_adp.php?p_faqid=116" target="_blank">Betting Rules</a>&nbsp;|&nbsp;<a class="FooterLinkDefault" onmouseover="this.className='FooterLinkMouseOver';" onmouseout="this.className='FooterLinkDefault';" href="http://www.nowwhere.com.au/nswtab/Locator/default.aspx" target="_blank">Find a TAB</a>&nbsp;|&nbsp;<a class="FooterLinkDefault" onmouseover="this.className='FooterLinkMouseOver';" onmouseout="this.className='FooterLinkDefault';" href="http://nettab.custhelp.com/cgi-bin/nettab.cfg/php/enduser/std_adp.php?p_faqid=396" target="_blank">PCL</a>&nbsp;|&nbsp;<a class="FooterLinkDefault" onmouseover="this.className='FooterLinkMouseOver';" onmouseout="this.className='FooterLinkDefault';" href="http://nettab.custhelp.com/cgi-bin/nettab.cfg/php/enduser/std_adp.php?p_sid=E*7UQveg&amp;p_lva=&amp;p_faqid=128" target="_blank">Privacy</a>&nbsp;|&nbsp;<a class="FooterLinkDefault" onmouseover="this.className='FooterLinkMouseOver';" onmouseout="this.className='FooterLinkDefault';" href="http://nettab.custhelp.com/cgi-bin/nettab.cfg/php/enduser/std_adp.php?p_sid=E*7UQveg&amp;p_lva=&amp;p_faqid=129" target="_blank">Terms of Use</a>&nbsp;|&nbsp;<span class="FooterStaticText">&copy; Tabcorp</span></td>

</tr>
</table>
									
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			<iframe id="formPopupFrame" name="formPopupFrame" frameborder="0" src="" style="display:none"></iframe>

			<iframe id="tipsPopupFrame" name="tipsPopupFrame" frameborder="0" src="" style="display:none"></iframe>	
			<div id="DIV_CMS_HOME" style="display:none"><TABLE cellSpacing="0" cellPadding="5" width="100%" border="0">
<TBODY>
<TR>
<TD style="FONT-WEIGHT: bold; FONT-SIZE: 18px; COLOR: #4169e1; FONT-FAMILY: arial, verdana" align="middle">Welcome to Express Bet</TD></TR></TBODY></TABLE>
<TABLE cellSpacing="10" cellPadding="0" width="100%" border="0">
<TBODY>
<TR>
<TD style="HEIGHT: 200px" vAlign="top" width="33%">
<TABLE height="100%" cellSpacing="0" cellPadding="5" width="100%" border="0">
<TBODY>
<TR>
<TD style="BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; FONT-WEIGHT: bold; FONT-SIZE: 12px; BACKGROUND: #6699cc; BORDER-LEFT: #cccccc 1px solid; COLOR: #000066; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: Arial; HEIGHT: 28px">Getting Started</TD></TR>

<TR>
<TD style="BORDER-RIGHT: #cccccc 1px solid; FONT-SIZE: 12px; VERTICAL-ALIGN: top; BORDER-LEFT: #cccccc 1px solid; LINE-HEIGHT: 16px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: Arial">To get started, simply click on any race in the <B>Next To Go</B> list on the left hand menu.<BR><BR>The Next To Go dropdown enables you to sort the race list by Galloping, Harness or Greyhound or by meeting name.<BR><BR><B>JOIN NOW!</B> - It only takes a few minutes to open a TAB Account and start betting online immediately! <A style="FONT-SIZE: 12px; FONT-FAMILY: Arial" href="http://nettab.custhelp.com/cgi-bin/nettab.cfg/php/enduser/std_adp.php?p_faqid=108">More</A></TD></TR></TBODY></TABLE></TD>
<TD style="HEIGHT: 200px" vAlign="top" width="33%">
<TABLE height="100%" cellSpacing="0" cellPadding="5" width="100%" border="0">
<TBODY>
<TR>
<TD style="BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; FONT-WEIGHT: bold; FONT-SIZE: 12px; BACKGROUND: #ffffcc; BORDER-LEFT: #cccccc 1px solid; COLOR: #000066; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: Arial; HEIGHT: 28px">Latest Update</TD></TR>

<TR>
<TD style="BORDER-RIGHT: #cccccc 1px solid; FONT-SIZE: 12px; VERTICAL-ALIGN: top; BORDER-LEFT: #cccccc 1px solid; LINE-HEIGHT: 16px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: Arial">Express Bet now enables customers to sort the runner information by Win or Place Approximate Dividends. <BR><BR>In addition, the runner selection columns are now adjacent to the Win and Place Approximate Dividends to enable easier bet placement.<BR><BR><A style="FONT-SIZE: 12px; LINE-HEIGHT: 16px; FONT-FAMILY: Arial" href="http://nettab.custhelp.com/cgi-bin/nettab.cfg/php/enduser/std_adp.php?p_faqid=238" target="_blank">Fixes and known issues since our last upgrade</A>.</TD></TR></TBODY></TABLE></TD>
<TD style="HEIGHT: 200px" vAlign="top" width="33%">
<TABLE height="100%" cellSpacing="0" cellPadding="5" width="100%" border="0">
<TBODY>
<TR>
<TD style="BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; FONT-WEIGHT: bold; FONT-SIZE: 12px; BORDER-LEFT: #cccccc 1px solid; COLOR: #000066; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: Arial; HEIGHT: 28px">tab.mobi - <EM>Put the TAB in your pocket</EM></SPAN></TD></TR>
<TR>
<TD style="BORDER-RIGHT: #cccccc 1px solid; FONT-SIZE: 12px; VERTICAL-ALIGN: top; BORDER-LEFT: #cccccc 1px solid; LINE-HEIGHT: 16px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: Arial"><A href="http://nettab.custhelp.com/cgi-bin/nettab.cfg/php/enduser/std_adp.php?p_faqid=367" target="_blank"><IMG src="http://www.tabinfo.com.au/images/tab.mobi_V2.gif" align="right" vspace="5" border="0"></A><STRONG>tab.mobi</STRONG> is TAB's mobile wagering solution. <BR><BR>To access simply enter <STRONG>tab.mobi</STRONG> into your internet enabled mobile browser.<BR><STRONG>tab.mobi</STRONG> gives you the freedom to bet wherever you are with your TAB internet account.<BR><BR><A href="http://nettab.custhelp.com/cgi-bin/nettab.cfg/php/enduser/std_adp.php?p_faqid=367" target="_blank">More</A></TD></TR></TBODY></TABLE></TD></TR>

<TR>
<TD style="HEIGHT: 255px" vAlign="top" width="33%">
<TABLE height="100%" cellSpacing="0" cellPadding="5" width="100%" border="0">
<TBODY>
<TR>
<TD style="BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; FONT-WEIGHT: bold; FONT-SIZE: 12px; BACKGROUND: #6699cc; BORDER-LEFT: #cccccc 1px solid; COLOR: #000066; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: Arial; HEIGHT: 28px">Batch Betting</TD></TR>
<TR>
<TD style="BORDER-RIGHT: #cccccc 1px solid; FONT-SIZE: 12px; VERTICAL-ALIGN: top; BORDER-LEFT: #cccccc 1px solid; LINE-HEIGHT: 16px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: Arial">Batch Betting enables you to place bets in the <A style="FONT-SIZE: 12px; FONT-FAMILY: Arial" onclick="window.open ('http://nettab.custhelp.com/cgi-bin/nettab.cfg/php/enduser/std_adp.php?p_faqid=266', 'newWin', 'scrollbars=yes,status=yes,width=800,height=600,resizable=yes')" href="javascript:void(0)">bet string format</A>. Up to 400 bets can be submitted at one time.<BR><BR>You can also build bets offline and then Submit the Batch File directly from your computer and you can save your list of Batch Bets to a file on your computer at any time.<BR><BR>Please visit our <A style="FONT-SIZE: 12px; FONT-FAMILY: Arial" onclick="window.open ('http://nettab.custhelp.com/cgi-bin/nettab.cfg/php/enduser/std_adp.php?p_faqid=266', 'newWin', 'scrollbars=yes,toolbar=yes,location=yes,status=yes,width=800,height=600,resizable=yes')" href="javascript:void()">Help Centre</A> for more information.</TD></TR></TBODY></TABLE></TD>

<TD style="HEIGHT: 255px" vAlign="top" width="33%">
<TABLE height="100%" cellSpacing="0" cellPadding="5" width="100%" border="0">
<TBODY>
<TR>
<TD style="BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; FONT-WEIGHT: bold; FONT-SIZE: 12px; BACKGROUND: #6699cc; BORDER-LEFT: #cccccc 1px solid; COLOR: #000066; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: Arial; HEIGHT: 28px">Expert Mode</TD></TR>
<TR>
<TD style="BORDER-RIGHT: #cccccc 1px solid; FONT-SIZE: 12px; VERTICAL-ALIGN: top; BORDER-LEFT: #cccccc 1px solid; LINE-HEIGHT: 16px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: Arial">This is a betting interface which provides the ability to place bets quickly without showing all the Approximate Dividend and Runner information for each race. <BR><BR>Simply click on the <B>EXPERT MODE</B> link at the top of the page to access it. When you want to return to the normal Express Bet mode simply click on <B>STANDARD MODE</B>.</TH> </TD></TR></TBODY></TABLE></TD>
<TD style="HEIGHT: 255px" vAlign="top" width="33%">

<TABLE height="100%" cellSpacing="0" cellPadding="5" width="100%" border="0">
<TBODY>
<TR>
<TD style="BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; FONT-WEIGHT: bold; FONT-SIZE: 12px; BACKGROUND: #6699cc; BORDER-LEFT: #cccccc 1px solid; COLOR: #000066; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: Arial; HEIGHT: 28px">Express Bet Preferences</TD></TR>
<TR>
<TD style="BORDER-RIGHT: #cccccc 1px solid; FONT-SIZE: 12px; VERTICAL-ALIGN: top; BORDER-LEFT: #cccccc 1px solid; LINE-HEIGHT: 16px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: Arial">Preference settings allow you to customise your Express Bet experience. Simply select the <B>My Account</B> drop down at the top of the page and select <B>Preferences</B>. <BR><BR>Preferences include; 
<LI>Set Flexi betting as your default betting option 
<LI>Select your default bet type, ie. Doubles, Trifecta, Quaddie etc. 
<LI>Set your maximum bet amount<BR><BR><SPAN style="FONT-WEIGHT: bold; FONT-SIZE: 11px; COLOR: red">PLEASE NOTE: THESE PREFERENCES ONLY APPLY TO EXPRESS BET</SPAN> <BR><BR>Please visit our <A style="FONT-SIZE: 12px; FONT-FAMILY: Arial" onclick="window.open ('http://nettab.custhelp.com/cgi-bin/nettab.cfg/php/enduser/std_adp.php?p_faqid=319', 'newWin', 'scrollbars=yes,toolbar=yes,location=yes,status=yes,width=800,height=600')" href="javascript:void(0)">Help Centre</A> for more information. </LI></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></div>		
		


<script type="text/javascript">
//<![CDATA[
var Jurisdiction = 'State=2';try{executeDeepMetrix('//deepmetrix.tab.com.au/dm.gif?');} catch (err) { }PmExpressMode = 'Standard';NumParlayFormulas = '6';var ParlayformulaInvalidPFNumberMessage = "Your formula number cannot be greater than the number of races selected.";var ParlayformulaRequiredMessage = "You must select a Formula.";var ParlayformulaInvalidLegsMessage  = "You must select at least 2 races for a Parlayformula bet.";BsBetTicketUrl = 'https://www.tab.com.au/Betting/BetTicket/DisplayClientSideBetTicket.aspx?State=2';var _currentLang = "3081";var _currentCurr = "AUD";ExpBetInit('http://www.skyracing.com.au/tab/form.php?State=2&Locale=en-au',
'http://www.skyracing.com.au/tab/tips.php?State=2&Locale=en-au',
'/CrossSiteAuth/OutboundRedirectSky.aspx?State=2',
'dest',
'Date',
'MeetingCode',
'RacingCode',
'RaceNumber');PmSetDefaultBetType('WinPlace');FocusFirstFormField();I18N_Validation_Init('At least one selection must be placed in first column.'
,'Insufficient Selections for this bet type.'
,'To create a boxed bet, please select the \'Box\' checkbox.'
,'The Flexi option is not available with a Mystery Bet.'
,'A bet amount is required for Win and/or Place.'
,'Bet amount is required.'
,'Bet cost exceeds Maximum bet amount. Please try again.'
,'Mystery bets cannot be added to batch. Click "Submit This Bet" to place a Mystery bet.'
,'Insufficient Selections in both legs.'
,'Insufficient Selections for in leg 1.'
,'Insufficient Selections in leg 2.'
,'You have encountered the following error on the page'
,'Maximum number of bets allowed in a batch is 400.'
,'Batch contains no bets.'
,'No race selected.',
'To access the TAB Daily Form Service you must login to your account or open a betting account with Tabcorp.',
'You can have a maximum of {0} Roving Selection for a {1}',
'You can have a maximum of {0} Standout',
'You have already selected this race number in your parlayformula bet',
'Invalid amount specified');I18N_Std_Init('Runner',
'Form',
'SCR',
'LSCR',
'Mystery - Single',
'Mystery - Boxed',
'Field - All Runners',
'Barrier',
'Box',
'Handicap',
'Jockey',
'Driver',
'Trainers',
'Gallops',
'Harness',
'Greyhounds',
'Win',
'Place',
'No Third Dividend',
'PLACE BETTING UNAVAILABLE',
'Vacant');PmInit('Standard', 'WinPlace', 'WinPlace', false, 1, true, 0.5, 999999.5);//]]>
</script>
</form>		
	</body>	
	<script type='text/javascript'>NtgChangeRace('R','L','2011-09-10T00:00:00','05',document.getElementById('2011-09-10T00:00:00RL05_Link2'));</script>		
</html>

Open in new window


for form is on line 6 the close of this form is on line 230
<form name="Form1" method="post" action="Default.aspx?State=2" id="Form1" style="height:100%;">

the iframe which refers to the login is on line 43

<iframe frameborder="0" width="100%" height="57px" src="../LoginFrame.aspx?ExpressBetMode=Standard" scrolling="no" id="LoginFrame" name="LoginFrame"></iframe>

This is the current code I am using

 
Public Sub RunBet()

        Dim objIE
        Dim strtext
        Dim strpasstext
        Dim strbutton

        strtext = "DisplayExpressTopNav1$TextboxLogin"
        strpasstext = "DisplayExpressTopNav1$TextboxPassword"
        strbutton = "DisplayExpressTopNav1$ButtonLogin"

        objIE = CreateObject("InternetExplorer.Application")

        objIE.Navigate("http://www.tab.com.au/ExpressBet/LoginFrame.aspx?State=2&ExpressBetMode=Standard")
        objIE.Visible = True

        While objIE.Busy = True
            Sleep(100)
        End While

        objIE.Document.form1.elements(strtext).Value = "1100214"
        objIE.Document.form1.elements(strpasstext).Value = "d230g3317"

        objIE.Document.form1.elements(strbutton).Click()

        While objIE.Busy = True
            Sleep(100)
        End While

        Dim t
        t = objIE.Document.DocumentElement.outerHTML

        Dim pattern As String = _
         "<!-- Account Number Label -->\s*<span id=""DisplayExpressTopNav1_LabelAccountNumber"" " & _
          "class=""LoginBarText"">Account: (\d+)</span>" & _
         "(?:\s*|.*?)*" & _
         "<!-- Balance -->\s*<span id=""DisplayExpressTopNav1_LabelBalance"" " & _
          "class=""LoginBarText"">Balance: \$(\d+\.\d+)</span>"

        Dim Match As Match, foundAccount, foundBalance
        Match = Regex.Match(t, pattern)
        If Match.Groups.Count = 3 Then
            foundAccount = Match.Groups(1).Value
            foundBalance = Match.Groups(2).Value

            Globals.Sheet3.Range("D11").Value = foundBalance
        End If
        objIE.Navigate("http://www.tab.com.au/ExpressBet/Standard/Default.aspx?State=2")

        While objIE.Busy = True
            Sleep(100)
        End While
        objIE.Document.all.BvTextArea.InnerText = "test value for textarea"
        Dim a
        For Each a In objIE.document.GetElementsByTagName("A")
            If a.innerText = "SUBMIT BATCH" Then
                a.Click()
                Exit For
            End If
        Next


    End Sub

Open in new window


What I did was from the code you supplied first which logs in
 at
objIE.Navigate("http://www.tab.com.au/ExpressBet/LoginFrame.aspx?State=2&ExpressBetMode=Standard")

then I nav to this page
objIE.Navigate("http://www.tab.com.au/ExpressBet/Standard/Default.aspx?State=2")

then used you second lot of code but it errors
maybe you could id the textarea in the form "Form1"

Hope this helps
0
 

Author Comment

by:Jason
ID: 36515322
This may help as well

Info
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 36516857
I'm wondering if the problem is mainly timing. Although the script waits for the IE object to be ready, it seems the iFrame is not always ready. Possibly it would have to wait for something else. At the moment there is another problem, the website has no races on...

I did test with a new page on my own site, that now contains an iframe as well, see if this works when they're back with races:

objIE.Document.frames("formPopupFrame").Document.all.BvTextArea.InnerText = "test value for textarea"
Dim a
For Each a In objIE.Document.frames("formPopupFrame").Document.GetElementsByTagName("A")

Open in new window


this replaces lines 53 - 55 from the code posted above.
0
 

Author Comment

by:Jason
ID: 36517541
Hi Robert

Just tested the new code still errors


 error
Thanks for your help I am definitely lost in this area
0
 

Author Comment

by:Jason
ID: 36517623
Hi Robert

Resolved the textarea problem you were right it was only time I extended the sleep to 1000 It works every time
        While objIE.Busy = True
            Sleep(1000)
        End While
        objIE.Document.all.BvTextArea.InnerText = "test value for textarea"

But the batch submit still not working with both codes
this the old code runs through but does not run the batch submit.
        Dim a
        For Each a In objIE.document.GetElementsByTagName("A")
            If a.innerText = "SUBMIT BATCH" Then
                a.Click()
                Exit For
            End If

then new code errors

 submit error
I clicked the submit batch it opens a new window

https://www.tab.com.au/ExpressBet/Submission/BetConfirmSummary.aspx?State=2

you get 2 options close which cancel the bet of submit which finalizes the bet

0
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 36521836
It's actually strange that the first part works now, it would mean that all elements of the iframes are also part of the global document tree. Maybe something else is going on, like an 'active' document, when you click in the browser?? But that would be strange as well.

Actually you have the best tool to make this work: in Visual Studio you should be able to select part of the line with the error, for example

objIE.Document.frames("formPopupFrame").Document

Open in new window


and then add a watch (from the right mouse button menu), and see if that contains sensible data or not, or errors as well.

Actually of course if the first line works without the frames(...) part then you would expect the second part to work without it as well. But if it runs through without finding anything, something else is happening. By the way it would be good just for checking to add a message box to the loop and see if does actually find anything:

Dim a
For Each a In objIE.document.GetElementsByTagName("A")
    MessageBox.Show("found an a: " & a.innerText)
    If a.innerText = "SUBMIT BATCH" Then
        a.Click()
        Exit For
    End If
Next

Open in new window

0
 

Author Closing Comment

by:Jason
ID: 36526848
Seems to be working fine now real weird

Your a legend

I will open a new post only a few more steps.  A popup now appears with a final submission we just need to accept this through the submit

then logout

Thanks again for your help I could not have don this without you thanks heaps
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now