我試圖利用我從這里獲得的vba代碼。當我運行該宏時,Selenium webdriver將檢索圖片的鏈接并將其放在Z#附近。然而,有時從網站上生成QR影像后,生成的QR影像會出現問題,無法移動到Y#單元并調整大小。
除錯會在Set Pshp = Selection.ShapeRange.Item(1)時提示,顯示 "物件不支持此屬性或方法 "的錯誤。
由于我需要為幾行資料生成QR碼,我目前正在逐行進行。
正如我所說,這個問題有時會發生,但頻率很高(90%的時間)。有誰介意一起解決這個問題嗎?謝謝
For i = 6 To Sheet2. Range("D" & Application.Rows.Count).End(xlUp).Row
Application.StatusBar = i - 1 & "/" & Sheet2. Range("D" & Application.Rows.Count).End(xlUp).Row - 1。
bot.FindElementByXPath("//input[contains(@type,'search')]").SendKeys (Sheet2.Range("D" & i)
bot.Wait 1500 1500
Report = bot.FindElementByLinkText("EN").Attribute("ref")
bot.Get報告
bot.Wait1500
QRurl = bot.FindElementByXPath("//img[contains(@src,'QRimages')]").Attribute("src"/span>)
Sheet2.Range("Z" & i).Value = QRurl
Sheet2.Pictures.Insert(QRurl).Select。
Set Pshp = Selection.ShapeRange.Item(1)
If Pshp Is Nothing Then GoTo lab
xcol = Sheet2.Range("Z" & i).Column - 1
Set xRg = Cells(Sheet2.Range("Z"/span> & i).Row, xcol)
With Pshp
.LockAspectRatio = msoFalse
If .Width > xRg.Width Then .Width = xRg.Width * 9 / 10 .
If .Height > xRg.Height Then .Height = xRg.Height * 9 / 102
.Left = xRg.Left (xRg.Width - .Width) / 2 .
.Placement = xlMoveAndSize
結束 與
lab:/span>
Set Pshp = Nothing
Range("Z6").Select
bot.Get "https://_/_/bulk_upload2_record.php"。
bot.Wait 1000 1000
Next i
uj5u.com熱心網友回復:
我發現我需要在我指定的作業表上運行宏,否則所有生成的影像將被卡在Z "i "處。我在 "導航 "作業表上指定了我的按鈕,這就是為什么它不能很好地作業。我試著在其他作業表上運行宏,結果也一樣。所以我的解決方案是在for回圈之前添加一行來激活sheet2。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/318374.html
標籤:
上一篇:ProcessBuilder啟動一個帶引數的.class檔案
下一篇:使用視圖系結與片段Android
