簡體   English   中英

打開從excel到Internet Explorer的一對一鏈接

[英]Open links from excel one by one to Internet Explorer

我在Excel中有100多個鏈接,我想在Internet Explorer中一個一個地打開它們。 分配給我的計算機有些慢,這就是為什么只需要在Internet Explorer的一個選項卡中打開鏈接的原因。

我想要:

1.從A1復制鏈接,將其粘貼到Internet Explorer。

2.等待頁面完全加載。

3.從A2復制鏈接,將其粘貼到Internet Explorer(相同的選項卡,而不打開新的選項卡)。

4.等待頁面完全加載。

5.重復步驟,直到帶有鏈接的“ A”的最后一個單元格。

在下面的代碼中,我可以從A1導航鏈接。 如何循環它從單元格1導航到單元格X。

Sub OpenInAnotherBrowser()
Dim iePath As String
Dim browser As String
Dim URL As String

iePath = "C:\Program Files\Internet Explorer\iexplore.exe"

If Dir(iePath) = "" Then pathie = "C:\Program Files\Internet Explorer\iexplore.exe"

URL = ActiveSheet.Range("A1").Value

If Dir(iePath) = "" Then
    If MsgBox("IE Not Found, Open with default browser?", vbQuestion + vbYesNo) = vbYes Then
        Application.FollowHyperlink URL
        Exit Sub
    End If
End If

Shell """" & iePath & """" & URL, vbHide

End Sub

此代碼循環通過sheet1中A列中的鏈接。 請注意斷開的鏈接和類似的內容,因為此代碼中沒有檢查這些內容。

Sub Main()

Dim IE As Object
Dim rngURL As Range
Dim rng As Range

' not perfect, but it is a quick way to keep VBA from looping through 1000000+ rows without using a bunch of ifs....
Set rngURL = Intersect(Sheet1.UsedRange, Sheet1.Columns("A"))

Set IE = CreateObject("internetexplorer.application")

IE.Visible = True

For Each rng In rngURL

    rng.Select

    If Trim(rng.Value) <> "" Then

        IE.Navigate Trim(rng.Value)

        Do While IE.ReadyState <> READYSTATE_COMPLETE
        Loop

        MsgBox IE.LocationURL ' This is just to slow things down a little bit

    End If

Next rng

IE.Quit

End Sub

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM