VBA:“htmlfile”参考什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20495035/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 00:53:27  来源:igfitidea点击:

VBA: What to reference for "htmlfile"?

htmlvbadom

提问by peter

I found the lines

我找到了线条

Set xmlHttp = CreateObject("MSXML2.XMLHTTP")
Set html = CreateObject("htmlfile")

and want to use them in my code. Only I like intellisense and option explicit, so I quickly modified the first one to

并想在我的代码中使用它们。只有我喜欢智能感知和选项显式,所以我很快将第一个修改为

'needs tools>references>microsoft xml, v5.0
Dim xmlHttp As MSXML2.xmlHttp: Set xmlHttp = New MSXML2.xmlHttp

My question is: how do i do the same thing for the second line? What do I need to reference to be able to write

我的问题是:我如何为第二行做同样的事情?我需要参考什么才能写

dim html as htmlfile

?

?

回答by Santosh

Go to Tools > Reference > Search for Microsoft HTML Object Library> tick the checkbox > OK

转到工具 > 参考 > 搜索 Microsoft HTML 对象库> 勾选复选框 > 确定

Now you can define html document element using early binding like below

现在你可以使用像下面这样的早期绑定来定义 html 文档元素

Dim html As HTMLDocument

Dim html As HTMLDocument

Using late binding you can use below which creates html document element.

使用后期绑定,您可以在下面使用它创建 html 文档元素。

Set html = CreateObject("htmlfile")

Set html = CreateObject("htmlfile")

enter image description here

在此处输入图片说明