在vbscript中是否可以执行以下操作?
Set xlApp = CreateObject("Excel.Application")
set xlBook = xlApp.WorkBooks.Open("filename.htm")
我查看了WorkBooks.Open的api,但是没有看到对文件名arg的任何限制。它必须是.xls或.xlsx文件吗?
(由于地震,我今天无法上班,所以我无法从我所处的位置开始尝试,但如果有可能,我会很高兴知道。)< / p>
答案 0 :(得分:0)
两个答案... 简短的回答是的,你可以... 长答案,您可以但不能在excel中但在Internet Explorer中显示html文件。
逻辑: 1-在excel上,创建一个按钮以执行VBA ... 2-将对象创建为IE ... set objIE = CreateObjcet(“ InternetExplorer.Application”) 2.1-导航到objIE.Navigate“ filename.htm” 2.2-将其显示为objIE.Visible true ...
这是一个示例:
Function openIE(webPage)
Set openIE = CreateObject("InternetExplorer.Application")
With openIE
If not .StatusBar then .StatusBar = True
If not .Visible then .Visible = True
If not .LocationURL = webPage then .Navigate webPage
If not .FullScreen then .FullScreen = True
End With
' Do Until is here because, the script is more faster then object.
' So, we need to make this script "talk" to the Internet Explorer.
Do Until openIE.ReadyState = 4
WScript.Sleep 250
Loop
End Function