Thắc mắc vì VBA báo lỗi từ dòng khai báo đầu (1 người xem)

Liên hệ QC

Người dùng đang xem chủ đề này

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:D" & 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
 

File đính kèm

  • error1.jpg
    error1.jpg
    23.4 KB · Đọc: 10
  • error2.jpg
    error2.jpg
    17.1 KB · Đọc: 11
Lần chỉnh sửa cuối:
Tôi đoán nguyên nhân lỗi do trong thư viện thiếu cái này: "SeleniumWraper Type Library"
 
Upvote 0
Bạn Leonguyenz ơi zậy mình phải khắc phục sao vậy?
 
Upvote 0
cho xin 500 file đi bạn. không có dữ liệu hay dữ liệu mẫu sao bít làm
bạn ơi mình cũng muốn đưa lắm nhưng cái này phải có thêm pass của trang web mới chạy được, mà cái này thì mình hok dám (@$%@. Chỉ là thắc mắc tại sao đang chạy ngon lành cả tuần nay mà mấy bữa nay lại ko hoạt động được (@$%@
 
Upvote 0
bạn ơi mình cũng muốn đưa lắm nhưng cái này phải có thêm pass của trang web mới chạy được, mà cái này thì mình hok dám (@$%@. Chỉ là thắc mắc tại sao đang chạy ngon lành cả tuần nay mà mấy bữa nay lại ko hoạt động được (@$%@

Vậy bạn có thể liên hệ với đồng nghiệp cũ làm ra cái này hỏi xem sao.
Mình dán vào file mình bị đỏ hết mấy dòng. Chắc là còn code khác liên quan đến code này.
Chắc là còn 1 sub selenium(.......)
 
Upvote 0
Upvote 0
Web KT

Bài viết mới nhất

Back
Top Bottom