1

次のコードを使用して、ドキュメントの列 A にある一連のリンクを開き、リンクを開いてから 3 秒待ってから次のページに移動するようにしますが、新しいウィンドウまたはタブを開く代わりに、単純にウィンドウを使用したいすでに開いています。

Sub OpenLinks()

For Each vCell In Range("A2:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set oIE = CreateObject("InternetExplorer.Application")
oIE.Visible = True
oIE.Navigate (vCell.Value)
Next vCell

End Sub
4

1 に答える 1

0

これを試して:

Sub OpenLinks()

Set oIE = CreateObject("InternetExplorer.Application")

For Each vCell In Range("A2:A" & Cells(Rows.Count, "A").End(xlUp).Row)
    oIE.Visible = True
    oIE.Navigate (vCell.Value)
    Application.Wait (Now + TimeValue("0:00:3"))
Next vCell

End Sub

ただし、いつものように、Setの代わりにWith /EndWithの使用を検討することをお勧めします。

Sub OpenLinks()  

With CreateObject("InternetExplorer.Application")

For Each vCell In Range("A2:A" & Cells(Rows.Count, "A").End(xlUp).Row)
    .Visible = True
    .Navigate (vCell.Value)
    Application.Wait (Now + TimeValue("0:00:3"))
Next vCell

End With

End Sub
于 2012-04-19T02:39:55.640 に答える