kimhang306
Thành viên mới

- Tham gia
- 2/6/15
- Bài viết
- 14
- Được thích
- 1
Chào mọi người, mình là thành viên mới, vì tính chất công việc nên mình xài VBA khá nhiều. Mọi người cho mình hỏi cách khắc phục khi VBA báo lỗi ngay từ dòng khai báo đầu tiên. Đây là file mà 1 nhân viên cũ làm sẵn, bình thường chạy rất ok, không hiểu sao hôm nay lại trổ chứng
. (nó bôi vàng ở dòng đầu tiên) Mọi người có thể chi cho mình rõ trục trặc như thế nào không? Cám ơn mọi người nhiều lắm
---Code:----
Sub ultimatethuocaz()
Dim selenium As New SeleniumWrapper.WebDriver
Dim shell: Set shell = CreateObject("WScript.Shell")
Dim z As Long
Dim Keys As New SeleniumWrapper.Keys
Dim MyData As DataObject
Dim strClip As String
Dim i As Long
Dim j As Long
selenium.Start "chrome", "http://abc.com/"
For z = 1253 To 1407
selenium.Open "http://abc.com/admin"
selenium.findElementByCssSelector(".search-field").Click
selenium.findElementByCssSelector(".search-field").SendKeys Sheets(1).Cells(z, 5).Value
selenium.SendKeys Keys.Enter
selenium.Wait 5000
selenium.findElementByCssSelector(".table>tbody:nth-child(1)>tr:nth-child(2)>td:nth-child(8)>div:nth-child(1)>a:nth-child(1)").Click
selenium.Wait 5000
For j = 2 To 2
selenium.findElementByCssSelector(Sheets("Find").Cells(j, 2).Value).Click
selenium.SendKeys Keys.Control & "a"
selenium.SendKeys Keys.Control
selenium.Wait 5000
selenium.SendKeys Keys.Control & "c"
selenium.SendKeys Keys.Control
selenium.Wait 5000
Set MyData = New DataObject
MyData.GetFromClipboard
strClip = MyData.getText
Sheets("Find").Cells(2, 1).Value = strClip
selenium.Wait 5000
For i = 2 To 2164
If Not i = z Then
If InStr(1, Sheets("Find").Cells(2, 1).Value, Sheets(1).Cells(i, 4).Value) > 0 Then
count = Sheets("Find").Range("C" & Rows.count).End(xlUp).Row + 1
Sheets("Find").Cells(count, 3).Value = Sheets(1).Cells(i, 4).Value
Sheets("Find").Cells(count, 4).Value = Sheets(1).Cells(i, 9).Value
End If
If InStr(1, Sheets("Find").Cells(2, 1).Value, Sheets(1).Cells(i, 5).Value) > 0 Then
count = Sheets("Find").Range("C" & Rows.count).End(xlUp).Row + 1
Sheets("Find").Cells(count, 3).Value = Sheets(1).Cells(i, 5).Value
Sheets("Find").Cells(count, 4).Value = Sheets(1).Cells(i, 9).Value
End If
End If
Next i
If Not Sheets("Find").Cells(2, 3).Value = "" Then
count = Sheets("Find").Range("C" & Rows.count).End(xlUp).Row
For i = 2 To count
Sheets("Find").Cells(i, 3).Select
Selection.Copy
selenium.findElementByCssSelector(Sheets("Find").Cells(j, 2).Value).Click
selenium.SendKeys Keys.Control & "f"
selenium.SendKeys Keys.Control
selenium.SendKeys Keys.Control & "v"
selenium.SendKeys Keys.Control
selenium.Wait 2000
selenium.SendKeys Keys.Enter
selenium.Wait 2000
selenium.findElementByCssSelector(".mce-close").Click
Sheets("Find").Cells(i, 4).Select
Selection.Copy
selenium.findElementByCssSelector(Sheets("Find").Cells(j, 8).Value).Click
selenium.SendKeys Keys.Control & "v"
selenium.SendKeys Keys.Control
selenium.SendKeys Keys.Enter
Next i
Sheets("Find").Range("C2
" & count).clear
End If
Next j
selenium.Wait 1000
Next z
End Sub
'#mceu_41
'#mceu_86
'#mceu_131
'#mceu_176
'#mceu_221
'#mceu_266

---Code:----
Sub ultimatethuocaz()
Dim selenium As New SeleniumWrapper.WebDriver
Dim shell: Set shell = CreateObject("WScript.Shell")
Dim z As Long
Dim Keys As New SeleniumWrapper.Keys
Dim MyData As DataObject
Dim strClip As String
Dim i As Long
Dim j As Long
selenium.Start "chrome", "http://abc.com/"
For z = 1253 To 1407
selenium.Open "http://abc.com/admin"
selenium.findElementByCssSelector(".search-field").Click
selenium.findElementByCssSelector(".search-field").SendKeys Sheets(1).Cells(z, 5).Value
selenium.SendKeys Keys.Enter
selenium.Wait 5000
selenium.findElementByCssSelector(".table>tbody:nth-child(1)>tr:nth-child(2)>td:nth-child(8)>div:nth-child(1)>a:nth-child(1)").Click
selenium.Wait 5000
For j = 2 To 2
selenium.findElementByCssSelector(Sheets("Find").Cells(j, 2).Value).Click
selenium.SendKeys Keys.Control & "a"
selenium.SendKeys Keys.Control
selenium.Wait 5000
selenium.SendKeys Keys.Control & "c"
selenium.SendKeys Keys.Control
selenium.Wait 5000
Set MyData = New DataObject
MyData.GetFromClipboard
strClip = MyData.getText
Sheets("Find").Cells(2, 1).Value = strClip
selenium.Wait 5000
For i = 2 To 2164
If Not i = z Then
If InStr(1, Sheets("Find").Cells(2, 1).Value, Sheets(1).Cells(i, 4).Value) > 0 Then
count = Sheets("Find").Range("C" & Rows.count).End(xlUp).Row + 1
Sheets("Find").Cells(count, 3).Value = Sheets(1).Cells(i, 4).Value
Sheets("Find").Cells(count, 4).Value = Sheets(1).Cells(i, 9).Value
End If
If InStr(1, Sheets("Find").Cells(2, 1).Value, Sheets(1).Cells(i, 5).Value) > 0 Then
count = Sheets("Find").Range("C" & Rows.count).End(xlUp).Row + 1
Sheets("Find").Cells(count, 3).Value = Sheets(1).Cells(i, 5).Value
Sheets("Find").Cells(count, 4).Value = Sheets(1).Cells(i, 9).Value
End If
End If
Next i
If Not Sheets("Find").Cells(2, 3).Value = "" Then
count = Sheets("Find").Range("C" & Rows.count).End(xlUp).Row
For i = 2 To count
Sheets("Find").Cells(i, 3).Select
Selection.Copy
selenium.findElementByCssSelector(Sheets("Find").Cells(j, 2).Value).Click
selenium.SendKeys Keys.Control & "f"
selenium.SendKeys Keys.Control
selenium.SendKeys Keys.Control & "v"
selenium.SendKeys Keys.Control
selenium.Wait 2000
selenium.SendKeys Keys.Enter
selenium.Wait 2000
selenium.findElementByCssSelector(".mce-close").Click
Sheets("Find").Cells(i, 4).Select
Selection.Copy
selenium.findElementByCssSelector(Sheets("Find").Cells(j, 8).Value).Click
selenium.SendKeys Keys.Control & "v"
selenium.SendKeys Keys.Control
selenium.SendKeys Keys.Enter
Next i
Sheets("Find").Range("C2

End If
Next j
selenium.Wait 1000
Next z
End Sub
'#mceu_41
'#mceu_86
'#mceu_131
'#mceu_176
'#mceu_221
'#mceu_266
File đính kèm
Lần chỉnh sửa cuối: