我可以将InternetExplorer.document写入另一个InternetExplorer窗口吗?

问题描述 投票:0回答:1

我想将一个窗口的IE.Document带入另一窗口的IE.Document。能做到吗?

excel vba mshtml
1个回答
0
投票

我看不出你的问题背后的含义。但是您可以通过以下方式做到这一点:

Sub DocFromIEtoIE()

Dim ieOne As Object
Dim ieTwo As Object
Dim nodeHTML As Object
Dim htmlDoc As String
Dim url As String

  url = "https://stackoverflow.com/"

  Set ieOne = CreateObject("internetexplorer.application")
  ieOne.Visible = True
  ieOne.navigate url
  Do Until ieOne.ReadyState = 4: DoEvents: Loop

  Set nodeHTML = ieOne.document.getElementsByTagName("html")(0)
  If Not nodeHTML Is Nothing Then
    htmlDoc = nodeHTML.outerHTML

    Set ieTwo = CreateObject("internetexplorer.application")
    ieTwo.Visible = True
    ieTwo.navigate "about:blank"
    Do Until ieTwo.ReadyState = 4: DoEvents: Loop

    ieTwo.document.Write (htmlDoc)
  End If
End Sub
© www.soinside.com 2019 - 2024. All rights reserved.