- 帖子
- 63
- 主題
- 13
- 精華
- 0
- 積分
- 122
- 點名
- 0
- 作業系統
- Windows
- 軟體版本
- office2007
- 閱讀權限
- 20
- 性別
- 女
- 註冊時間
- 2015-4-22
- 最後登錄
- 2019-7-19
|
各位前輩好!~
我是剛接觸VBA不久的初學者,
我在錄製巨集的過程中碰到問題
在這個網頁中http://patft.uspto.gov/netahtml/PTO/search-adv.htm
打入關鍵字ttl/mouse and abst/Function
搜尋後,我以錄製巨集的方式匯入excel,
通常第一頁匯入是OK的,
第二頁後會出現太複雜無法錄製(似乎因為網址太長),
所以我直接複製第一頁的巨集,並將網址更改成第二頁的網址後,成功匯入!
第三頁(最後一頁)
以上面方式操作,執行後excel整個會轉不停,最後無回應
我實在找不出原因來...
或是各位前輩有其他vba撰寫方式,可以將每次搜尋結果(每次搜尋結果可能會變動)匯入excel
請各位前輩指點迷津~~非常感謝!!
以下是我的第一頁程式碼,2.3頁只有更改網址而已
Sub 第一頁()
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PTO2&Sect2=HITOFF&u=%2Fnetahtml%2FPTO%2Fsearch-adv.htm&r=0&f=S&l=50&d=PTXT&RS=%28TTL%2Fmouse+AND+ABST%2FFunction%29&Refine=Refine+Search&Query=ttl%2Fmouse+and+abst%2FFunction" _
, Destination:=Range("$A$1"))
.Name = _
"nph-Parser?Sect1=PTO2&Sect2=HITOFF&u=%2Fnetahtml%2FPTO%2Fsearch-adv.htm&r=0&f=S&l=50&d=PTXT&RS=%28TTL%2Fmouse+AND+ABST%2FFunction%29&Refine=Refine+Search&Query=ttl%2Fmouse+and+abst%2FFunction"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "2"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub |
|