Jason
asked on
I need to send a string from excel cell to website textarea and sudmit form part 3
Popup occurs on Submit Batch
With this popup I need a few things I need the valid bets value, the invalid bet value, Total Bets value and the Cost Total Valid bets
Globals.Sheet1.Range("B1") .value = valid
Globals.Sheet1.Range("B2") .value = invalid
Globals.Sheet1.Range("B3") .value = total
Globals.Sheet1.Range("B4") .value = cost
Then I need to submit the form
code for submit
<input type="submit" name="LinkButtonSubmit" value="SUBMIT" onclick="if (typeof(Page_ClientValidat e) == 'function') { if (Page_ClientValidate() == false) { return false; }} this.disabled = true;this.style.cursor='wa it';__doPo stBack('Li nkButtonSu bmit',''); WebForm_Do PostBackWi thOptions( new WebForm_PostBackOptions(&q uot;LinkBu ttonSubmit ", "", true, "", "", false, false))" id="LinkButtonSubmit" class="ButtonSubmitBatchBe t" onmouseover="this.style.cu rsor='poin ter'" />
Once this is all done then its a matter of logout and close explorer
With this popup I need a few things I need the valid bets value, the invalid bet value, Total Bets value and the Cost Total Valid bets
Globals.Sheet1.Range("B1")
Globals.Sheet1.Range("B2")
Globals.Sheet1.Range("B3")
Globals.Sheet1.Range("B4")
Then I need to submit the form
code for submit
<input type="submit" name="LinkButtonSubmit" value="SUBMIT" onclick="if (typeof(Page_ClientValidat
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head><title>
BetConfirmSummary
</title><link href="/Shared/Styles/sty_express.css?v=5.14.2.0" rel="stylesheet" type="text/css" /></head>
<body>
<form name="Form1" method="post" action="BetConfirmSummary.aspx?State=2" onsubmit="javascript:return WebForm_OnSubmit();" id="Form1">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTcxMjIyNDA0OA9kFgICBA9kFg4CAQ9kFgQCAQ8PFgIeCEltYWdlVXJsBSgvU2hhcmVkL0ltYWdlcy9FeHByZXNzQmV0L2VuLWF1L2xvZ28uanBnZGQCAw8WAh4EVGV4dAUaQmV0IENvbmZpcm1hdGlvbiAtIFN1bW1hcnlkAgkPFgIfAQUBMGQCDw8WAh8BBQExZAISDw8WAh4HVmlzaWJsZWdkFgICAQ8PFgIeC05hdmlnYXRlVXJsBUAvRXhwcmVzc0JldC9TdWJtaXNzaW9uL0JldENvbmZpcm1EZXRhaWwuYXNweD9TdGF0ZT0yJnZhbGlkPWZhbHNlZGQCFg8WAh8BBQExZAIbDxYCHwEFATBkAiQPFgIfAQU+PGEgaHJlZj0iIyIgb25jbGljaz0iY3JDb25maXJtQ2xvc2VCdXR0b25DbGlja2VkKCk7Ij5DTE9TRTwvYT5kZF4XvEt+1/vr/pk5eqiABg4Fam3O" />
</div>
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['Form1'];
if (!theForm) {
theForm = document.Form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
<script src="/WebResource.axd?d=bR6C-CV5y3I7IIexwpGorw2&t=634460542334285863" type="text/javascript"></script>
<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/ConfirmReceiptCompiled.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="/WebResource.axd?d=cpgqkQQsdROXLnDXjSjTxE73oq8ShhCLEOxKAjC9XMA1&t=634460542334285863" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
return true;
}
//]]>
</script>
<div>
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgKr8N2LAQK6xufABlyK8HZhKTqUq2w+SHB3ElVRAUqt" />
</div>
<table height="100%" cellspacing="0" cellpadding="0" width="100%" border="0">
<tr valign="top" align="left">
<td colspan="2">
<table cellspacing="0" cellpadding="0" width="100%" border="0">
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0" id="Header">
<tr height="50">
<td width="120" align="left" valign="top" id="padRight"><img id="PageHeader1_ImageExpress" src="/Shared/Images/ExpressBet/en-au/logo.jpg" alt="RaceTAB" style="height:45px;width:120px;border-width:0px;" /></td>
<td align="left" valign="middle" class="padLeft whiteText padRight"><b><span id="spanHeader">Bet Confirmation - Summary</span></b></td>
<td align="right" valign="middle" class="padRight whiteText padBottom">
<div id="PageHeader1_PanelPrint">
<a href="javascript:void(crMakeDivPrintable())"><img height="17" hspace="3" src="/Shared/Images/ExpressBet/en-au/gra_icon_print.gif"
width="18" align="middle" border="0" alt="" />
<span id="PageHeader1_LabelPrint">print</span></a>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" align="left">
<span id="CustomValidatorPage" class="redText" style="display:none;"></span>
<table cellspacing="0" cellpadding="5" width="100%" border="0">
<tr>
<td class="padleft10 lightBlue borderTop borderRight borderBottom" valign="top" align="left"
rowspan="3"><b>Summary:</b></td>
<td class="padleft10 lightBlue borderTop" align="left"><b>Valid Bets:</b></td>
<td class="padleft10 lightBlue borderTop" align="left"><b>0</b></td>
<td class="padleft10 lightBlue borderTop" align="left">
</td>
</tr>
<tr>
<td class="padleft10 lightBlue" align="left"><b>Invalid Bets:</b></td>
<td class="padleft10 lightBlue" align="left"><b>1</b></td>
<td class="padleft10 lightBlue" align="left"><span id="LabelMaxBetCost" class="redText"></span><div id="PanelInvalidDetails">
<b>(<a id="HyperLinkInvalidDetails" href="/ExpressBet/Submission/BetConfirmDetail.aspx?State=2&valid=false">click here for details</a>)</b>
</div></td>
</tr>
<tr>
<td class="padleft10 lightBlue borderBottom" align="left"><b>Total Bets:</b></td>
<td class="padleft10 lightBlue borderBottom" align="left"><b>1</b></td>
<td class="padleft10 lightBlue borderBottom" align="left"> </td>
</tr>
<tr>
<td class="padleft10 lightGrey borderRight"><b>Cost: </b></td>
<td class="padleft10 lightGrey"><b>Total Valid Bets (0) Cost =</b></td>
<td class="padleft10 lightGrey" colspan="2"><span id="LabelTotalAmountForiegn" class="boldText">$0.00</span><br/>
</td>
</tr>
<tr align="left">
<td class="padleft10 redText" colspan="4"><b>Once you select submit, bets cannot be cancelled. To continue to place your bet click Submit.</b></td>
</tr>
<tr align="right">
<td class="padright10" colspan="4">
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="ButtonGrey"><a href="#" onclick="crConfirmCloseButtonClicked();">CLOSE</a></td>
</tr>
</table>
</td>
<td><b>or</b></td>
<td>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="ButtonBlue"><input type="submit" name="LinkButtonSubmit" value="SUBMIT" onclick="if (typeof(Page_ClientValidate) == 'function') { if (Page_ClientValidate() == false) { return false; }} this.disabled = true;this.style.cursor='wait';__doPostBack('LinkButtonSubmit','');WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("LinkButtonSubmit", "", true, "", "", false, false))" id="LinkButtonSubmit" class="ButtonSubmitBatchBet" onmouseover="this.style.cursor='pointer'" /></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<script type="text/javascript">
//<![CDATA[
var Page_Validators = new Array(document.getElementById("CustomValidatorPage"));
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
var CustomValidatorPage = document.all ? document.all["CustomValidatorPage"] : document.getElementById("CustomValidatorPage");
CustomValidatorPage.display = "Dynamic";
CustomValidatorPage.evaluationfunction = "CustomValidatorEvaluateIsValid";
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
var Jurisdiction = 'State=2';try{executeDeepMetrix('//deepmetrix.tab.com.au/dm.gif?');} catch (err) { }crResizeWindow(640,530);
FocusFirstFormField();
var Page_ValidationActive = false;
if (typeof(ValidatorOnLoad) == "function") {
ValidatorOnLoad();
}
function ValidatorOnSubmit() {
if (Page_ValidationActive) {
return ValidatorCommonOnSubmit();
}
else {
return true;
}
}
//]]>
</script>
</form>
</body>
</html>
Once this is all done then its a matter of logout and close explorer
For other experts, see also previous question: https://www.experts-exchange.com/questions/27294498/Excel-string-to-website-textarea-and-submit.html
I'll try and have a look later but in the mean time a couple of questions:
- how those the second pop-up open?
- tiny mistake I assume the closing balance goes in B9?
I'll try and have a look later but in the mean time a couple of questions:
- how those the second pop-up open?
- tiny mistake I assume the closing balance goes in B9?
ASKER
Yeah sorry B9
When you click the submit from the first popup it displays the second screen in the same window
So not a true popup as such I will get the code for this
thanks
When you click the submit from the first popup it displays the second screen in the same window
So not a true popup as such I will get the code for this
thanks
I'm afraid I can't test this because I can't "click" the Submit link, it gives an error about not being logged in, so I can't try out how to access the popup.
ASKER
do you have a private email I could pass on the acc and pass for you to test
I've sent you an email to the address in your profile, if that's not current you can find me through my profile (basically any name under schutt.nl will do but I normally use my first name. There is one tiny problem of course. EE is meant to provide solutions that are ideally also helpful to others in more or less the same situation. With this part of the process not available publicly, any solution will be private to you. Now in this case the better part of the process is available in the previous questions so I hope nobody else stumbles across this part of it which will probably be useless to them.
ASKER
I am happy to make the code available with out the account details
This will help others to deliver a process to achieve a workable solution
This will help others to deliver a process to achieve a workable solution
Agreed, I'll have another look with the credentials you supplied, which I will keep to myself of course.
Argh, races done for the day I guess...
I've been such a moron. I kept on testing in VBA / VBS, but now I've made a VS project with a helper module to simulate Excel. Actually, something nice coming out of this I think, maybe it will be of help to someone. I'll post it later, but for now at least you know I'm able to test much more efficiently.
ASKER
That's cool so are you still getting something out of the journey as well??
Absolutely, exploring this stuff is exciting for me as well! I'm currently looking into some example code which taps into the windows list because it seems the pop-up is not available through the DOM of the opened IE.
Finally I'm making progress.
Here is the code, a lot of changes!
Also, you need to add a reference to a dll to your project: %windir%\system32\shdocvw. dll
You do that with menu Project, Add Reference, tab Browse and then enter the file.
With me the code is in Form1, you can put that in your own project's function, note objIE is now global although that's actually only for SleepLoop:
Note that some commands you need to delete, like Tabcontrol1.selectedindex. ..
For general reference, I created a module to place values in a datagrid like you place them in the excel sheets. So these are for others who want to try this out and not for your project!
Here is the code, a lot of changes!
Also, you need to add a reference to a dll to your project: %windir%\system32\shdocvw.
You do that with menu Project, Add Reference, tab Browse and then enter the file.
With me the code is in Form1, you can put that in your own project's function, note objIE is now global although that's actually only for SleepLoop:
Imports System.Threading.Thread
Imports System.Text.RegularExpressions
Public Class Form1
Dim objIE = Nothing
Const C_acc As String = "USERNAME"
Const C_pwd As String = "PASSWORD"
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
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
SleepLoop(100)
Dim t As String
t = objIE.Document.DocumentElement.outerHTML.ToString()
If Not t.Contains("Account: " & C_acc) Then ' already logged in?
objIE.Document.form1.elements(strtext).Value = C_acc
objIE.Document.form1.elements(strpasstext).Value = C_pwd
objIE.Document.form1.elements(strbutton).Click()
SleepLoop(100)
t = objIE.Document.DocumentElement.outerHTML.ToString()
'not possible like this: these texts always exist...
'If t.Contains("Your account number is invalid") Or t.Contains("Please enter your password") Or t.Contains("Your password must be") Then objIE.Quit() : objIE = Nothing : Exit Sub
End If
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
Me.TabControl1.SelectedIndex = 2
Globals.Sheet3.Range("D11").Value = foundBalance
End If
objIE.Navigate("http://www.tab.com.au/ExpressBet/Standard/Default.aspx?State=2")
SleepLoop(100)
'SleepLoop(1000) ' extra sleep for iFrames?
Dim rs As String = ""
Do
Try
rs = objIE.Document.all.formPopupFrame.readyState
Catch ex As Exception
Sleep(200)
End Try
Loop Until rs = "complete"
If Not objIE.Document.DocumentElement.outerHTML.ToString.Contains("No racing available for betting") Then ' stopped for the day
objIE.Document.all.BvTextArea.InnerText = "test test test value for textarea"
Dim a
For Each a In objIE.document.GetElementsByTagName("A")
If a.innerText = "SUBMIT BATCH" Then
a.Click() ' NOTE: allow pop-ups...
Exit For
End If
Next
' now find the pop-up window
Dim objWin As Object = Nothing
Do
Sleep(1000)
objWin = FindPopupWindow("BetConfirmSummary")
Loop Until objWin IsNot Nothing
t = objWin.body.innerHTML.ToString.Replace(vbCr, "").Replace(vbLf, "")
pattern = "<tr>\s*<td[^>]*>\s*<b>\s*Summary\s*:\s*</b>\s*</td>\s*<td[^>]*>\s*<b>\s*Valid\s*Bets\s*:\s*</b>\s*</td>\s*<td[^>]*>\s*<b>\s*(\d+)\s*</b>\s*</td>\s*<td[^>]*>.*?</td>\s*</tr>\s*" & _
"<tr>\s*<td[^>]*>\s*<b>\s*Invalid\s*Bets\s*:\s*</b>\s*</td>\s*<td[^>]*>\s*<b>\s*(\d+)\s*</b>\s*</td>\s*<td[^>]*>.*?</td>\s*</tr>\s*" & _
"<tr>\s*<td[^>]*>\s*<b>\s*Total\s*Bets\s*:\s*</b>\s*</td>\s*<td[^>]*>\s*<b>\s*(\d+)\s*</b>\s*</td>\s*<td[^>]*>.*?</td>\s*</tr>\s*" & _
"<tr>\s*<td[^>]*>\s*<b>\s*Cost\s*:\s*</b>\s*</td>\s*<td[^>]*>\s*<b>\s*Total\s*Valid\s*Bets\s*\(\d+\)\s*Cost\s*=\s*</b>\s*</td>\s*<td[^>]*>\s*<span[^>]*>\s*\$\s*(\d+\.\d\d)\s*</span>"
Dim Match3 As Match
Match3 = Regex.Match(t, pattern, RegexOptions.IgnoreCase)
If Match3.Groups.Count = 5 Then
Me.TabControl1.SelectedIndex = 0
Globals.Sheet1.Range("B1").Value = Match3.Groups(1).Value
Globals.Sheet1.Range("B2").Value = Match3.Groups(2).Value
Globals.Sheet1.Range("B3").Value = Match3.Groups(3).Value
Globals.Sheet1.Range("B4").Value = Match3.Groups(4).Value
' SET BREAKPOINT HERE!
objWin.all.form1.submit() ' ???
'Globals.Sheet1.Range("B5").Value = submitted
'Globals.Sheet1.Range("B6").Value = accepted
'Globals.Sheet1.Range("B7").Value = rejected
'Globals.Sheet1.Range("B8").Value = openbal
'Globals.Sheet1.Range("B9").Value = closingbal
End If
End If
End Sub
Sub SleepLoop(ms)
While objIE.Busy = True
Sleep(ms)
End While
End Sub
Public Function FindPopupWindow(t As String) As Object
Dim SWs As New SHDocVw.ShellWindows
Dim IE As SHDocVw.InternetExplorer
For Each IE In SWs
If IE.LocationName.Equals(t) Then
Return IE.Document
End If
Next
Return Nothing
End Function
End Class
Note that some commands you need to delete, like Tabcontrol1.selectedindex.
For general reference, I created a module to place values in a datagrid like you place them in the excel sheets. So these are for others who want to try this out and not for your project!
Module Globals
Public Sheet1 As New Worksheet(Form1.Sheet1)
Public Sheet3 As New Worksheet(Form1.Sheet3)
Public Class Worksheet
Public myGrid As DataGridView
Public Sub New(o As DataGridView)
myGrid = o
End Sub
Public ReadOnly Property Range(x) As DataGridViewCell
Get
Dim c As Integer = GetCol(x) ' columns must be added first!
Dim r As Integer = GetRow(x)
Return myGrid.Rows(r - 1).Cells(c - 1)
End Get
End Property
Private Function GetRow(x)
Dim n, ret As Integer
ret = 0
For n = 1 To Len(x)
If IsNumeric(Mid(x, n + 1)) Then ret = CInt(Mid(x, n + 1)) : Exit For
Next
If myGrid.Rows.Count < ret Then myGrid.Rows.Add(ret - myGrid.Rows.Count)
Return ret
End Function
Private Function GetCol(x)
Dim n, ret
ret = 0
For n = 1 To Len(x)
If IsNumeric(Mid(x, n + 1)) Then ret = Asc(Left(x, n)) - Asc("A") + 1
Next
If myGrid.Columns.Count < ret Then
While myGrid.Columns.Count < ret
myGrid.Columns.Add("col" & (myGrid.Columns.Count + 1), Chr(Asc("A") + myGrid.Columns.Count))
End While
End If
Return ret
End Function
End Class
End Module
the extra wait function after logging in still doesn't work I think, need to think of something else. However, after the 'crash' you can continue and it works...
at the point of the submit in the popup now I'm stuck because I don't know if I can submit this (invalid) bet...?
at the point of the submit in the popup now I'm stuck because I don't know if I can submit this (invalid) bet...?
ASKER
I placed the first lot of code in the module1 and error occurred
1 SleepLoop objIE is not declared
2 popup function SHDocVw.ShellWindows abd SHDocVw.InternetExplorer errors
1 SleepLoop objIE is not declared
2 popup function SHDocVw.ShellWindows abd SHDocVw.InternetExplorer errors
ASKER
I don't need the second lot of code do I???
Because you are using a form the datagrid sits in your form right so therefore I don't need it right???
Because you are using a form the datagrid sits in your form right so therefore I don't need it right???
There were a couple of remarks above the code, I repeat them here more clearly I hope:
* you need to add a reference to a dll to your project: %windir%\system32\shdocvw. dll
You do that with menu Project, Add Reference, tab Browse and then enter the file.
* objIE is now global although that's actually only for SleepLoop, so outside of the sub this is in, I've declared:
* you need to add a reference to a dll to your project: %windir%\system32\shdocvw.
You do that with menu Project, Add Reference, tab Browse and then enter the file.
* objIE is now global although that's actually only for SleepLoop, so outside of the sub this is in, I've declared:
Dim objIE = Nothing
Correct, the second lot of code is for people like me who don't have Visual Studio professional with the possibility to create an "Excel project".
ASKER
don't read all sorry
ASKER
K thats what the dll ref was for I see now
That's ok, we're gonna get there. Now also be careful to put a breakpoint on the last submit. It probably doesn't work anyway but we need to check what's in that "second pop-up". And/or I need to know if I can proceed with the submit from there or that would mean it costs money...
ASKER
got excited and you know didn't read properly
But all cool now done can't test till tomorrow though
But all cool now done can't test till tomorrow though
ASKER
test day is coming woohoo
okay great. Well I'm off now for the evening, enjoy!
ASKER
you can press the final submit due to the invalid bet it does nothing
see img in comment above ID: 36528304
that where the rest of the information needs to be captured same comment ref
see img in comment above ID: 36528304
that where the rest of the information needs to be captured same comment ref
ASKER
robert
a few things sleeploop didn't work so bypassed by just using sleep
also the popup now does not display information
I also tested through website and there is no website issues so the only thing is there must be something in the coding that as creating the problem
I could not check coding beyond this do to this error
Can you have a look
Thanks
a few things sleeploop didn't work so bypassed by just using sleep
also the popup now does not display information
I also tested through website and there is no website issues so the only thing is there must be something in the coding that as creating the problem
I could not check coding beyond this do to this error
Can you have a look
Thanks
ASKER
It funny it works if you step through the code but fails if you just run the code
It's working for me now, but only in the debugger. After the navigate/submit parts we need a better way to wait for the page to be fully loaded. The easiest way is probably to keep checking for the element(s) we need in the page with a try/catch/sleep/retry block.
The last piece of code (replaces lines 104 - 111 from previous post, but obviously other line numbers in your project) is:
Then after that, probably once more repeat the first line of this bit (the submit) for the last step.
Also I think there needs to be a lot more error checking, and quit() + close() on objWin and objIE of course.
The last piece of code (replaces lines 104 - 111 from previous post, but obviously other line numbers in your project) is:
objWin.forms(0).submit()
t = objWin.body.innerHTML.ToString.Replace(vbCr, "").Replace(vbLf, "")
pattern = "<tr>\s*<td[^>]*>\s*<b>\s*Summary\s*:\s*</b>\s*</td>\s*<td[^>]*>\s*<b>\s*Bets\s*Submitted\s*:\s*</b>\s*</td>\s*<td[^>]*>\s*<b>\s*(\d+)\s*</b>\s*</td>\s*<td[^>]*>.*?</td>\s*</tr>\s*" & _
"<tr>\s*<td[^>]*>\s*<b>\s*Bets\s*Accepted\s*:\s*</b>\s*</td>\s*<td[^>]*>\s*<b>\s*(\d+)\s*</b>\s*</td>\s*<td[^>]*>.*?</td>\s*</tr>\s*" & _
"<tr>\s*<td[^>]*>\s*<b>\s*Bets\s*Rejected\s*:\s*</b>\s*</td>\s*<td[^>]*>\s*<b>\s*(\d+)\s*</b>\s*</td>\s*<td[^>]*>.*?</td>\s*</tr>\s*" & _
"<tr>\s*<td[^>]*>\s*<b>\s*Balances\s*:\s*</b></td>\s*<td[^>]*>\s*<b>\s*Opening\s*Balance\s*:\s*</b>\s*</td>\s*<td[^>]*>\s*<span[^>]*>\s*\$\s*(\d+\.\d\d)\s*</span>\s*</td>\s*</tr>\s*" & _
"<tr>.*?</tr>\s*" & _
"<tr>\s*<td[^>]*>\s*<b>\s*Closing\s*Balace\s*:\s*</b>\s*</td>\s*<td[^>]*>\s*<span[^>]*>\s*\$\s*(\d+\.\d\d)\s*</span>\s*</td>\s*</tr>"
Dim Match4 As Match
Match4 = Regex.Match(t, pattern, RegexOptions.IgnoreCase)
If Match4.Groups.Count = 6 Then
Globals.Sheet1.Range("B5").Value = Match4.Groups(1).Value
Globals.Sheet1.Range("B6").Value = Match4.Groups(2).Value
Globals.Sheet1.Range("B7").Value = Match4.Groups(3).Value
Globals.Sheet1.Range("B8").Value = Match4.Groups(4).Value
Globals.Sheet1.Range("B9").Value = Match4.Groups(5).Value
End If
Then after that, probably once more repeat the first line of this bit (the submit) for the last step.
Also I think there needs to be a lot more error checking, and quit() + close() on objWin and objIE of course.
ASKER
The original code work great but the new code is erroring bad for me I dont know why.
Is the a way to migrate your original code with the new code Ill show you what I have done
At the moment the problem I am having with the new code is the loop does not break
The value of objWin remains nothing
Do
Sleep(1000)
objWin = FindPopupWindow("BetConfir mSummary")
Loop Until objWin IsNot Nothing
Public Function FindPopupWindow(ByVal t As String) As Object
Dim SWs As New SHDocVw.ShellWindows
Dim IE As SHDocVw.InternetExplorer
For Each IE In SWs
If IE.LocationName.Equals(t) Then
Return IE.Document
End If
Next
Return Nothing
End Function
Cant do any further testing tonight races over will take a further look in the morning.
Is the a way to migrate your original code with the new code Ill show you what I have done
At the moment the problem I am having with the new code is the loop does not break
The value of objWin remains nothing
Do
Sleep(1000)
objWin = FindPopupWindow("BetConfir
Loop Until objWin IsNot Nothing
Public Function FindPopupWindow(ByVal t As String) As Object
Dim SWs As New SHDocVw.ShellWindows
Dim IE As SHDocVw.InternetExplorer
For Each IE In SWs
If IE.LocationName.Equals(t) Then
Return IE.Document
End If
Next
Return Nothing
End Function
Cant do any further testing tonight races over will take a further look in the morning.
'This is your original code which works great
Dim objIE
Dim strtext
Dim strpasstext
Dim strbutton
Dim strbutton1
strtext = "DisplayExpressTopNav1$TextboxLogin"
strpasstext = "DisplayExpressTopNav1$TextboxPassword"
strbutton = "DisplayExpressTopNav1$ButtonLogin"
strbutton1 = "LinkButtonSubmit"
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 = "d23g0p317"
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("D16").Value = foundBalance
End If
objIE.Navigate("http://www.tab.com.au/ExpressBet/Standard/Default.aspx?State=2")
While objIE.Busy = True
Sleep(1000)
End While
objIE.Document.all.BvTextArea.InnerText = "test value for textarea"
Dim a
For Each a In objIE.document.GetElementsByTagName("A")
'MessageBox.Show("found an a: " & a.innerText)
Sleep(100)
If a.innerText = "SUBMIT BATCH" Then
a.Click()
Exit For
End If
Next
While objIE.Busy = True
Sleep(100)
End While
'This is your new code
' now find the pop-up window
Dim objWin As Object = Nothing
Do
Sleep(1000)
objWin = FindPopupWindow("BetConfirmSummary")
Loop Until objWin IsNot Nothing
t = objWin.body.innerHTML.ToString.Replace(vbCr, "").Replace(vbLf, "")
pattern = "<tr>\s*<td[^>]*>\s*<b>\s*Summary\s*:\s*</b>\s*</td>\s*<td[^>]*>\s*<b>\s*Valid\s*Bets\s*:\s*</b>\s*</td>\s*<td[^>]*>\s*<b>\s*(\d+)\s*</b>\s*</td>\s*<td[^>]*>.*?</td>\s*</tr>\s*" & _
"<tr>\s*<td[^>]*>\s*<b>\s*Invalid\s*Bets\s*:\s*</b>\s*</td>\s*<td[^>]*>\s*<b>\s*(\d+)\s*</b>\s*</td>\s*<td[^>]*>.*?</td>\s*</tr>\s*" & _
"<tr>\s*<td[^>]*>\s*<b>\s*Total\s*Bets\s*:\s*</b>\s*</td>\s*<td[^>]*>\s*<b>\s*(\d+)\s*</b>\s*</td>\s*<td[^>]*>.*?</td>\s*</tr>\s*" & _
"<tr>\s*<td[^>]*>\s*<b>\s*Cost\s*:\s*</b>\s*</td>\s*<td[^>]*>\s*<b>\s*Total\s*Valid\s*Bets\s*\(\d+\)\s*Cost\s*=\s*</b>\s*</td>\s*<td[^>]*>\s*<span[^>]*>\s*\$\s*(\d+\.\d\d)\s*</span>"
Dim Match3 As Match
Match3 = Regex.Match(t, pattern, RegexOptions.IgnoreCase)
If Match3.Groups.Count = 5 Then
'Me.TabControl1.SelectedIndex = 0
Globals.Sheet1.Range("B1").Value = Match3.Groups(1).Value
Globals.Sheet1.Range("B2").Value = Match3.Groups(2).Value
Globals.Sheet1.Range("B3").Value = Match3.Groups(3).Value
Globals.Sheet1.Range("B4").Value = Match3.Groups(4).Value
' SET BREAKPOINT HERE!
objWin.all.form1.submit() ' ???
'Globals.Sheet1.Range("B5").Value = submitted
'Globals.Sheet1.Range("B6").Value = accepted
'Globals.Sheet1.Range("B7").Value = rejected
'Globals.Sheet1.Range("B8").Value = openbal
'Globals.Sheet1.Range("B9").Value = closingbal
End If
can you follow the debugger into the FindPopupWindow function and see if something goes wrong there?
ASKER
ASKER
ASKER
I understand about the t now in the FindPopupWindow function the t = BetConfirmSummary while the locationname = "TAB Sportsbet - Horse Racing - Greyhound Racing - Harness Racing" so they are never equal and will not give a value to objWin
Does the popup not appear then? In the part before this code the "a.Click" should click on the submit link and open the popup window. Actually that is one of the points where we need some more error checking: if the correct 'a' is not found then the popup doesn't open. Unfortunately I'm not sure what to do in that case other than try again and maybe hope in the mean time the document has loaded completely:
Dim blnFoundSubmit As Boolean = False
Do
Dim a
For Each a In objIE.document.GetElementsByTagName("A")
If a.innerText = "SUBMIT BATCH" Then
a.Click() ' NOTE: allow pop-ups...
blnFoundSubmit = True
Exit For
End If
Next
If blnFoundSubmit Then
objIE.Document.all.BvTextArea.InnerText = "test test test value for textarea"
Else
Sleep(200)
End If
Loop Until blnFoundSubmit
ASKER
Yes the popup appears but for some reason the only locationname that gets displayed is the original window
I added a count in the code to see how many ie windows was open it resulted in only 1
so it appears the it is not identifying the popup window
I added a count in the code to see how many ie windows was open it resulted in only 1
so it appears the it is not identifying the popup window
ASKER
The error checking is back to front you need to apply the text to textarea before submiting the a.click otherwise it will submit without text
Ai, it could be dependant on a setting. Something like 'show separate windows in taskbar', if that's off then maybe there's only 1 window.
There was another way to find windows and/or processes, I'm gonna need some time to dig into that again because the way I used now was easy to get to the .document of the IE window, and with the other routine I'm not so sure...
There was another way to find windows and/or processes, I'm gonna need some time to dig into that again because the way I used now was easy to get to the .document of the IE window, and with the other routine I'm not so sure...
oh yeah, you're right I was going to do the click after setting the text but forgot, just move the line "a.Click" down, the variable a should still be set. The reason for this is avoiding the error when the document is not loaded yet.
ASKER
Public Function FindPopupWindow(ByVal t As String) As Object
Dim SWs As New SHDocVw.ShellWindows
Dim IE As SHDocVw.InternetExplorer
Dim count As Integer
count = SWs.Count
For Each IE In SWs
If IE.LocationName.Equals(t) Then
Return IE.Document
End If
Next
Return Nothing
End Function
Dim SWs As New SHDocVw.ShellWindows
Dim IE As SHDocVw.InternetExplorer
Dim count As Integer
count = SWs.Count
For Each IE In SWs
If IE.LocationName.Equals(t) Then
Return IE.Document
End If
Next
Return Nothing
End Function
ASKER
done the a.click
No, sorry, just checked it and it's wrong or at least dangerous. Use this instead:
Dim blnFoundSubmit As Boolean = False
Do
Dim a
Dim objFoundSubmit As Object = Nothing
For Each a In objIE.document.GetElementsByTagName("A")
If a.innerText = "SUBMIT BATCH" Then
objFoundSubmit = a
blnFoundSubmit = True
Exit For
End If
Next
If blnFoundSubmit Then
objIE.Document.all.BvTextArea.InnerText = "test test test value for textarea"
objFoundSubmit.Click() ' NOTE: allow pop-ups...
Else
Sleep(200)
End If
Loop Until blnFoundSubmit
Hey, how stupid an idea is this: Aren't you using FireFox? Is it possible to try with IE as your default browser?
ASKER
Just been reading
link: http://support.microsoft.com/kb/176792
says that I should add reference mshtml.dll do you think this may have anything to do with it????
link: http://support.microsoft.com/kb/176792
says that I should add reference mshtml.dll do you think this may have anything to do with it????
ASKER
yeah I can default IE don't really see what that has to do with it because the popup open in separate window and in IE and all the coding points to IE
But stranger things have happened and I'll give it a go
But stranger things have happened and I'll give it a go
ASKER
I cant check till in the morning no races at the moment
ASKER
Tested with IE Default no different. I also opened 3 extra IE windows at the time of debugging.
The code cycles through the 3 opened IE windows and the parent IE window but It does not recognize the popup window.
This is a child window but the parent window does not recognize it as a child which is strange.
Also windows does not recognize it as an open IE window I am at a loss
The code cycles through the 3 opened IE windows and the parent IE window but It does not recognize the popup window.
This is a child window but the parent window does not recognize it as a child which is strange.
Also windows does not recognize it as an open IE window I am at a loss
ASKER
Found something interesting I opened IE when to tab.com.au logged in and pressed submit batch.
Popup window came up which is all good.
I then ran the app in debug which opened another IE window cycled through code and popup window opened
what is interesting is the when you cycled through the opened IE windows in the code it recognized the first opened popup window but not the popup window opened by the script
So something in the script for some reason is preventing the popup window being recognized
This is going to be a hard one
Popup window came up which is all good.
I then ran the app in debug which opened another IE window cycled through code and popup window opened
what is interesting is the when you cycled through the opened IE windows in the code it recognized the first opened popup window but not the popup window opened by the script
So something in the script for some reason is preventing the popup window being recognized
This is going to be a hard one
Yes, it's a bit of a mystery but we can try a number of things. The dll ref is not in my project but if anything, could have the effect of making other object definitions available in debugging. I just tried to add it but there was an error. I added mshtml.tlb though, that works. I see why you would need it now; in the original code is the line: "If TypeOf Doc Is HTMLDocument", this type is probably imported from mshtml but I didn't use it in my code.
If you open a simple Windows Explorer it should also be shown in the list. On my (windows 7) system it shows the names of every (tabbed) website I have open (and a number of blank ones).
I was looking at a number of sites that describe registering a browser helper object but it looks to me that if it's not absolutely necessary we shouldn't go that route...
Another possibility I looked at earlier was using a WebBrowser object in my form but I don't know if that would be an option in your Excel project?
If you open a simple Windows Explorer it should also be shown in the list. On my (windows 7) system it shows the names of every (tabbed) website I have open (and a number of blank ones).
I was looking at a number of sites that describe registering a browser helper object but it looks to me that if it's not absolutely necessary we shouldn't go that route...
Another possibility I looked at earlier was using a WebBrowser object in my form but I don't know if that would be an option in your Excel project?
ASKER
working now man how bad is that needed a sleep(1000) in submit batch
If blnFoundSubmit Then
objIE.Document.all.BvTextA rea.InnerT ext = "test test test value for textarea"
a.Click() ' NOTE: allow pop-ups...
Sleep(1000)
If blnFoundSubmit Then
objIE.Document.all.BvTextA
a.Click() ' NOTE: allow pop-ups...
Sleep(1000)
ASKER
now not working again
ASKER
Does this mean anything or even help
Link: http://www.xtremevbtalk.com/showthread.php?t=311518
Hi all, it seems that IE does not register in the ROT (Running Object Table) if invoked using a startup script at login.
If I log in, close the IE session, and re-open IE, it DOES appear when cycling through Shellwindows. I am guessing that the IE invoked at startup uses the .dll rather than the .exe, and therefore is not being registered.
For now I will just ask the user to close and re-open IE, but it is a pretty clumsy workaround. If anyone has any suggestions on how I can either
a) locate and attach to the running instance of IE, or
b) register the running instance in the ROT
then I'd much appreciate it.
Thanks!
Link: http://www.xtremevbtalk.com/showthread.php?t=311518
Hi all, it seems that IE does not register in the ROT (Running Object Table) if invoked using a startup script at login.
If I log in, close the IE session, and re-open IE, it DOES appear when cycling through Shellwindows. I am guessing that the IE invoked at startup uses the .dll rather than the .exe, and therefore is not being registered.
For now I will just ask the user to close and re-open IE, but it is a pretty clumsy workaround. If anyone has any suggestions on how I can either
a) locate and attach to the running instance of IE, or
b) register the running instance in the ROT
then I'd much appreciate it.
Thanks!
It does seem to reference a similar discrepancy as we're experiencing but no solution...
I'll have another look at creating a Browser Helper Object, that seems to be a way forward.
I'll have another look at creating a Browser Helper Object, that seems to be a way forward.
I'm not getting the BHO. Let's try something else:
I've made a number of changes now, I've added the reference to shdocvw and also added at the top of the code:
Now you can use correct typing like:
Remember, I had put this as a global variable, this becomes more important now, also add there:
Also, I've copied some declarations to use library functions from windows, outside of functions, maybe you need to put these in a separate global module.
Then, after all that, you can use this modified FindPopupWindow function and sub-function:
Now this doesn't do anything new yet, but in your case this will not find the window on main level and will call the EnumChildWindows. On my system it doesn't find the SubmitBet window there but maybe on yours it does, so could you try this and see what output it gives in the debug/immediate window?
I've made a number of changes now, I've added the reference to shdocvw and also added at the top of the code:
Imports mshtml
Imports SHDocVw
Now you can use correct typing like:
Dim objIE As InternetExplorer = Nothing
Remember, I had put this as a global variable, this becomes more important now, also add there:
Dim _findName As String = ""
Dim _foundWnd As IntPtr = IntPtr.Zero
Also, I've copied some declarations to use library functions from windows, outside of functions, maybe you need to put these in a separate global module.
Public Delegate Function EnumWindowsProc(ByVal hwnd As IntPtr, ByVal lParam As Int32) As Boolean
Public Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As IntPtr, ByVal lpEnumFunc As EnumWindowsProc, ByVal lParam As Int32) As IntPtr
Public Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As IntPtr, ByVal lpString As String, ByVal cch As Int32) As Int32
Public Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As IntPtr) As Int32
Then, after all that, you can use this modified FindPopupWindow function and sub-function:
Public Function FindPopupWindow(ByVal t As String) As InternetExplorer
Dim SWs As New ShellWindows
Dim IE As InternetExplorer
Debug.Print("SWs.Count = " & SWs.Count)
For Each IE In SWs
Debug.Print("IE.LocationName = " & IE.LocationName)
Debug.Print("IE.LocationURL = " & IE.LocationURL)
If IE.LocationName.Equals(t) Then
Return IE
End If
Next
' not found as main window; look for child window
_findName = t
EnumChildWindows(objIE.HWND, AddressOf FindChildWindow, 0)
Return Nothing
End Function
Private Function FindChildWindow(ByVal hwnd As IntPtr, ByVal lParam As Int32) As Boolean
Dim str As String = String.Empty.PadLeft(GetWindowTextLength(hwnd) + 1)
GetWindowText(hwnd, str, str.Length)
If Not String.IsNullOrEmpty(str.Substring(0, str.Length - 1)) Then
Debug.Print("found window: " & str.Substring(0, str.Length - 1))
If str.StartsWith(_findName) Then
_foundWnd = hwnd
Return False ' stop enumerating
End If
End If
FindChildWindow = True
End Function
Now this doesn't do anything new yet, but in your case this will not find the window on main level and will call the EnumChildWindows. On my system it doesn't find the SubmitBet window there but maybe on yours it does, so could you try this and see what output it gives in the debug/immediate window?
ASKER
the code in your vb app works well went through it with debug and all is good. Strange how problems occur when working it through excel. It may be better to code it as an app. Didn't really want to do that a lot more coding involved and I thought by using excel would cut down on the coding (the easy way out).
Do you think we can resolve this using excel?????
Do you think we can resolve this using excel?????
Uhm, I didn't expect that! So you're saying that in Excel the SWs.count stays 1, but in the vb app it's 2 and the popup window is found?
Maybe just maybe the fact that the popup is not shown as a separate window is due to an option in Excel, can you have a look for the option to show separate windows on the taskbar and switch it?
Maybe just maybe the fact that the popup is not shown as a separate window is due to an option in Excel, can you have a look for the option to show separate windows on the taskbar and switch it?
ASKER
yes the vb app count is actually 3 testExcel, tab parent page and BetConfirmSummary where are when the script is executed through excel the count is 1 tab parent page.
Windows 7 allow you to combined windows just turned that off. Just tested no difference with windows feature off.
Looking into problems with excel executing ShellWindows.
There is no options in excel that relates to grouped windows or anything to do with IE popups
Windows 7 allow you to combined windows just turned that off. Just tested no difference with windows feature off.
Looking into problems with excel executing ShellWindows.
There is no options in excel that relates to grouped windows or anything to do with IE popups
As you can probably tell, the difference really baffles me. In Excel 2007 there is an option to show all windows under Advanced-Display. It shouldn't matter but I'm grasping at straws here...
That last error; I'm wondering if you have in fact made objIE global?
That last error; I'm wondering if you have in fact made objIE global?
ASKER
I have 2007 and show all windows is ticked
As for the globals I placed them at the start of the module to my understanding that makes them global they are not set in a function
So I think that's right.
Maybe it just cant be done inside and office environment. Perhaps it can only regognise that parent instance
What I might do is create a webpage with a popup instance and run some code across it to see.
This will help to see if it is due to something being passed by the parent page the prevent the instance being seen or whether it might be a bug in the dll
As for the globals I placed them at the start of the module to my understanding that makes them global they are not set in a function
So I think that's right.
Maybe it just cant be done inside and office environment. Perhaps it can only regognise that parent instance
What I might do is create a webpage with a popup instance and run some code across it to see.
This will help to see if it is due to something being passed by the parent page the prevent the instance being seen or whether it might be a bug in the dll
Imports Microsoft.VisualStudio.Tools.Applications.Runtime
Imports Office = Microsoft.Office.Core
Imports Tools = Microsoft.Office.Tools.Excel
Imports Microsoft.Office.Interop
Imports Login = BetBotv2.au.com.tab.login
Imports Racing = BetBotv2.au.com.tab.racing
Imports System
Imports System.IO
Imports System.Xml
Imports System.Threading.Thread
Imports System.Text.RegularExpressions
Imports mshtml
Imports SHDocVw
Module Module_Bet
Public Delegate Function EnumWindowsProc(ByVal hwnd As IntPtr, ByVal lParam As Int32) As Boolean
Public Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As IntPtr, ByVal lpEnumFunc As EnumWindowsProc, ByVal lParam As Int32) As IntPtr
Public Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As IntPtr, ByVal lpString As String, ByVal cch As Int32) As Int32
Public Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As IntPtr) As Int32
Dim objIE As InternetExplorer = Nothing
Dim _findName As String = ""
Dim _foundWnd As IntPtr = IntPtr.Zero
I found some more possibilities to find an IE window and get to the document. If that works on your system, we need to remove ".Document" from the calling code because this returns a document, so a level lower than the previous code.
I haven't gotten it to work though, so nothing new to post yet.
I haven't gotten it to work though, so nothing new to post yet.
So, a short recap of what I've tried:
- list all main windows, find IE windows, get handle to document, doesn't work. I found some reference to Active Accessibility but that seems to be something from the past...
- list all processes, try the same, same problem, can't get ObjectFromLresult to work.
- maybe a new lead (from http://msdn.microsoft.com/en-us/magazine/cc163723.aspx ): start IE as a process instead of ActiveX object:
outside the function add:
at the top, if needed, add:
instead of CreateObject("InternetExpl orer.Appli cation") use:
And then the next line that follows is: "Dim t As String" after which the login is done.
- list all main windows, find IE windows, get handle to document, doesn't work. I found some reference to Active Accessibility but that seems to be something from the past...
- list all processes, try the same, same problem, can't get ObjectFromLresult to work.
- maybe a new lead (from http://msdn.microsoft.com/en-us/magazine/cc163723.aspx ): start IE as a process instead of ActiveX object:
outside the function add:
Shared documentComplete As New AutoResetEvent(False)
Private Shared Sub ie_DocumentComplete(ByVal pDisp As Object, ByRef URL As Object)
documentComplete.Set()
End Sub
at the top, if needed, add:
Imports System.Threading
instead of CreateObject("InternetExpl
Dim p As Process = Process.Start("iexplore.exe", "about:blank")
If p Is Nothing Then Exit Sub
Dim allBrowsers As ShellWindows = New SHDocVw.ShellWindows()
If allBrowsers.Count = 0 Then Exit Sub
Sleep(2000) ' checking too quickly errors out!
For i As Integer = 0 To allBrowsers.Count - 1
Dim objIEtemp As InternetExplorer = allBrowsers.Item(i)
Try
If objIEtemp.HWND = p.MainWindowHandle Then objIE = objIEtemp : Exit For
Catch ex As Exception
'Console.WriteLine("Error: " & ex.Message)
End Try
Next
If objIE Is Nothing Then Exit Sub
AddHandler objIE.DocumentComplete, AddressOf ie_DocumentComplete
objIE.Navigate("http://www.tab.com.au/ExpressBet/LoginFrame.aspx?State=2&ExpressBetMode=Standard")
documentComplete.WaitOne()
And then the next line that follows is: "Dim t As String" after which the login is done.
ASKER
Hey Robert
earlier in the code
Shared documentComplete As New AutoResetEvent(False)
Private Shared Sub ie_DocumentComplete(ByVal pDisp As Object, ByRef URL As Object)
documentComplete.Set()
End Sub
It requested that I dim shared and delete shared from Private Shared Sub so done that
Then it says objIE.DocumentComplete is not an object which would be right as it was declared as New AutoResetEvent(False)
Error 1 'DocumentComplete' is not an event of 'Object'. C:\Projects\BetBotv3\BetBo tv3\BetBot v3\Module_ Bet.vb 104 26 BetBotv3
How should I fix this
Thanks
earlier in the code
Shared documentComplete As New AutoResetEvent(False)
Private Shared Sub ie_DocumentComplete(ByVal pDisp As Object, ByRef URL As Object)
documentComplete.Set()
End Sub
It requested that I dim shared and delete shared from Private Shared Sub so done that
Then it says objIE.DocumentComplete is not an object which would be right as it was declared as New AutoResetEvent(False)
Error 1 'DocumentComplete' is not an event of 'Object'. C:\Projects\BetBotv3\BetBo
How should I fix this
Thanks
Can you try changing the declaration for objIE. I haven't used this myself previously but I think it's the correct syntax:
Dim WithEvents objIE As InternetExplorer = Nothing
Dim WithEvents objIE As InternetExplorer = Nothing
If the DocumentComplete doesn't work, forget it for now, the SleepLoop does more or less the same, just trying to make it a bit more robust but it may be distracting from the real subject, does the popup get found by FindPopupWindow when the IE is created in this different way?
ASKER
it doesn't fix the problem count still 1 with 2 IE open and sees the main page as the first.
Hmm, another dead end I'm afraid then. I will need some time to think again...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Robert it was a long road with this one. Your a legend and thanks immensely for your help
Jason
Jason
ASKER
Globals.Sheet1.Range("B5")
Globals.Sheet1.Range("B6")
Globals.Sheet1.Range("B7")
Globals.Sheet1.Range("B8")
Globals.Sheet1.Range("B8")
we need to proceed to close