sgkdnay
Technical User
- Aug 4, 2008
- 21
I know I did decent job on coding (considering learning by the book & hard way), anyhoo... I can't, for the life of me, figure out why Listview isn't capturing all the data, I checked the web and it was loading fast like it was supposed to, but the Listview isn't inputting the data quick enuff before the web update its query.
Mind you that I don't have direct access to the database with the company, hence why I use innerHTML. Care to give me some insight what I'm doing wrong or could do to improve this coding?
On Error Resume Next
Dim NextRow As Long
Dim CountToSave As Long
Dim CountSets As Long
Dim x As Long
Dim endx As Long
Dim ReturnedText As String
Dim CurRow As Long
Dim sta As Variant 'test
Dim abc As Variant 'test
SArray(1) = "AL"
SArray(2) = "AK"
SArray(3) = "AZ"
SArray(4) = "AR"
SArray(5) = "CA"
'sarray continues down to 50 states
AArray(1) = "A"
AArray(2) = "B"
AArray(3) = "C"
AArray(4) = "D"
AArray(5) = "E"
'aarray continues down to (26 letters)
ColumnCount = 5
CountToSave = 0
LastSaveMark = 1
CList.ListItems.Clear
endx = CRM.Document.body.All.tags("td").length
RowCount = CountRows
NextRow = 0
CurColumn = 0
CurRow = 1
TriggerNewRow = True
tmrClock.Enabled = True 'timer
tmrclock_Timer 'timer
For Each sta In SArray 'test
For Each abc In AArray 'test
Text1.Text = abc 'checking if goes thru arrays (temp information to verify if it works)
Text2.Text = sta 'checking if goes thru arrays (temp information to verify if it works)
CRM.Document.getElementById("name").focus
CRM.Document.myform.Name.Value = abc 'input name
CRM.Document.getElementById("status").focus 'test
SendKeys "{s}" 'send s to dropmenu
CRM.Document.getElementById("state").focus
CRM.Document.myform.State.Value = sta 'input state abbrev
CRM.Document.getElementById("SearchIt").focus
CRM.Document.getElementById("SearchIt").Click 'pull new data
Do: DoEvents: Loop Until CRM.Busy = False
For x = 0 To endx
DoEvents
ReturnedText = ""
ReturnedText = Trim(ReturnAfterRemoval(CRM.Document.body.All.tags("td").Item(x).innerText)) 'remove data i dont want in listview
If ReturnedText = "No Leads Found" Then
If TriggerNewRow = True Then
NextRow = CList.ListItems.Count + 1
CList.ListItems.Add
CList.ListItems.Item(NextRow).Text = CurRow
TriggerNewRow = False
End If
Else
If Not ReturnedText = "" Then
'Sleep (5)
CurColumn = CurColumn + 1
If TriggerNewRow = True Then
NextRow = CList.ListItems.Count + 1
CList.ListItems.Add
CList.ListItems.Item(NextRow).Text = CurRow
TriggerNewRow = False
End If
If CurColumn >= ColumnCount Then
CList.ListItems.Item(NextRow).SubItems(CurColumn) = ReturnedText
CurRow = CurRow + 1
CurColumn = 0
TriggerNewRow = True
Else
CList.ListItems.Item(NextRow).SubItems(CurColumn) = ReturnedText
End If
End If
End If
Sleep (5)
Next x
Next abc
Next sta
tmrClock.Enabled = False
End Function
Mind you that I don't have direct access to the database with the company, hence why I use innerHTML. Care to give me some insight what I'm doing wrong or could do to improve this coding?
On Error Resume Next
Dim NextRow As Long
Dim CountToSave As Long
Dim CountSets As Long
Dim x As Long
Dim endx As Long
Dim ReturnedText As String
Dim CurRow As Long
Dim sta As Variant 'test
Dim abc As Variant 'test
SArray(1) = "AL"
SArray(2) = "AK"
SArray(3) = "AZ"
SArray(4) = "AR"
SArray(5) = "CA"
'sarray continues down to 50 states
AArray(1) = "A"
AArray(2) = "B"
AArray(3) = "C"
AArray(4) = "D"
AArray(5) = "E"
'aarray continues down to (26 letters)
ColumnCount = 5
CountToSave = 0
LastSaveMark = 1
CList.ListItems.Clear
endx = CRM.Document.body.All.tags("td").length
RowCount = CountRows
NextRow = 0
CurColumn = 0
CurRow = 1
TriggerNewRow = True
tmrClock.Enabled = True 'timer
tmrclock_Timer 'timer
For Each sta In SArray 'test
For Each abc In AArray 'test
Text1.Text = abc 'checking if goes thru arrays (temp information to verify if it works)
Text2.Text = sta 'checking if goes thru arrays (temp information to verify if it works)
CRM.Document.getElementById("name").focus
CRM.Document.myform.Name.Value = abc 'input name
CRM.Document.getElementById("status").focus 'test
SendKeys "{s}" 'send s to dropmenu
CRM.Document.getElementById("state").focus
CRM.Document.myform.State.Value = sta 'input state abbrev
CRM.Document.getElementById("SearchIt").focus
CRM.Document.getElementById("SearchIt").Click 'pull new data
Do: DoEvents: Loop Until CRM.Busy = False
For x = 0 To endx
DoEvents
ReturnedText = ""
ReturnedText = Trim(ReturnAfterRemoval(CRM.Document.body.All.tags("td").Item(x).innerText)) 'remove data i dont want in listview
If ReturnedText = "No Leads Found" Then
If TriggerNewRow = True Then
NextRow = CList.ListItems.Count + 1
CList.ListItems.Add
CList.ListItems.Item(NextRow).Text = CurRow
TriggerNewRow = False
End If
Else
If Not ReturnedText = "" Then
'Sleep (5)
CurColumn = CurColumn + 1
If TriggerNewRow = True Then
NextRow = CList.ListItems.Count + 1
CList.ListItems.Add
CList.ListItems.Item(NextRow).Text = CurRow
TriggerNewRow = False
End If
If CurColumn >= ColumnCount Then
CList.ListItems.Item(NextRow).SubItems(CurColumn) = ReturnedText
CurRow = CurRow + 1
CurColumn = 0
TriggerNewRow = True
Else
CList.ListItems.Item(NextRow).SubItems(CurColumn) = ReturnedText
End If
End If
End If
Sleep (5)
Next x
Next abc
Next sta
tmrClock.Enabled = False
End Function