Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用InternetExplorer.Application对象在VBA中打开HTMLDocument对象_Vba - Fatal编程技术网

如何使用InternetExplorer.Application对象在VBA中打开HTMLDocument对象

如何使用InternetExplorer.Application对象在VBA中打开HTMLDocument对象,vba,Vba,在Access VBA中,我想创建一个HTML文档对象,并使用InternetExplorer.Application对象打开它,而不必保存HTML文档。知道下面的代码会导致运行时错误“5”:无效的过程调用或参数,是否有类似的代码可以实现这一点 Dim Explorer As Object Dim HTMLDoc As HTMLDocument Set HTMLDoc = CreateObject("htmlfile") HTMLDoc.body.innerHTML = &

在Access VBA中,我想创建一个HTML文档对象,并使用InternetExplorer.Application对象打开它,而不必保存HTML文档。知道下面的代码会导致运行时错误“5”:无效的过程调用或参数,是否有类似的代码可以实现这一点

Dim Explorer As Object
Dim HTMLDoc As HTMLDocument

Set HTMLDoc = CreateObject("htmlfile")
HTMLDoc.body.innerHTML = "<h1>This is a test.</h1>"
Set Explorer = CreateObject("InternetExplorer.Application")
Explorer.navigate HTMLDoc
Dim资源管理器作为对象
将HTMLDoc设置为HTMLDocument
设置HTMLDoc=CreateObject(“htmlfile”)
HTMLDoc.body.innerHTML=“这是一个测试。”
Set Explorer=CreateObject(“InternetExplorer.Application”)
Explorer.HTMLDoc

您不需要中间
htmlfile
对象

Dim Explorer As Object
Set Explorer = CreateObject("InternetExplorer.Application")
With Explorer
    .Visible = True
    .navigate "about:blank"
    .document.body.innerHTML = "<h1>This is a test.</h1>"
End With
Dim资源管理器作为对象
Set Explorer=CreateObject(“InternetExplorer.Application”)
与探险家
.Visible=True
.导航“关于:空白”
.document.body.innerHTML=“这是一个测试。”
以

为什么要使用中间
htmlfile
?@TimWilliams我试图简化这个问题。我要做的是从一个表中加载一个HTML主体模板,使用我的表单值在模板中插入一些值,然后在InternetExplorer中打开它。如果有更简单的方法,我愿意接受建议。你不能直接在IE中打开模板并在那里使用它吗?@TimWilliams你的意思是直接在IE中编辑HTML的内容?是的-它应该与你的
htmlfile