简体   繁体   English

打开从excel到Internet Explorer的一对一链接

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

I have more than 100 links in Excel and I want to open them in Internet Explorer one by one. 我在Excel中有100多个链接,我想在Internet Explorer中一个一个地打开它们。 The computer assigned to me is somewhat slow that is why the links need to be opened in just one tab of Internet Explorer. 分配给我的计算机有些慢,这就是为什么只需要在Internet Explorer的一个选项卡中打开链接的原因。

I want to: 我想要:

1.Copy link from A1, paste it to Internet Explorer. 1.从A1复制链接,将其粘贴到Internet Explorer。

2.Wait until the page is fully loaded. 2.等待页面完全加载。

3.Copy link from A2, paste it to Internet Explorer (same tab, not opening a new tab). 3.从A2复制链接,将其粘贴到Internet Explorer(相同的选项卡,而不打开新的选项卡)。

4.Wait until the page is fully loaded. 4.等待页面完全加载。

5.Repeat steps until the last cell of "A" with links. 5.重复步骤,直到带有链接的“ A”的最后一个单元格。

In the code below, I can navigate the link from A1. 在下面的代码中,我可以从A1导航链接。 How can you loop it that it will navigate from cell 1 to cell X. 如何循环它从单元格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

This code loops through the links in column A in sheet1. 此代码循环通过sheet1中A列中的链接。 Look out for broken links and things like that as there are no check for those things in this code. 请注意断开的链接和类似的内容,因为此代码中没有检查这些内容。

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