[英]Is it possible to open a .htm file in Excel using vbscript?
Is it possible in vbscript to do something like the following?是否可以在 vbscript 中执行以下操作?
Set xlApp = CreateObject("Excel.Application")
set xlBook = xlApp.WorkBooks.Open("filename.htm")
I looked at the api for WorkBooks.Open, but couldn't see any restrictions on the filename arg.我查看了 WorkBooks.Open 的 api,但看不到对文件名 arg 的任何限制。 Does it have to be a .xls or .xlsx file?
它必须是 .xls 或 .xlsx 文件吗?
(I can't get to a work today because of an earthquake so I can't really try it out from where I am, but would be good to know in advanced if this is possible.) (由于地震,我今天无法上班,所以我无法真正从我所在的地方进行尝试,但如果可能的话,最好提前知道。)
two answer... short answer yes you can... long answer, you can, but not gonna show the html file in excel but in Internet Explorer.两个答案...简短的回答是的,你可以...长的回答,你可以,但不会在 excel 中显示 html 文件,而是在 Internet Explorer 中。
Logics: 1 - On excel, create a button to execute the VBA... 2 - create object as IE... set objIE = CreateObjcet("InternetExplorer.Application") 2.1 - Navigate to the objIE.Navigate "filename.htm" 2.2 - put it visible objIE.Visible true ...逻辑: 1 - 在 excel 上,创建一个按钮来执行 VBA... 2 - 创建对象为 IE... set objIE = CreateObjcet("InternetExplorer.Application") 2.1 - 导航到 objIE.Navigate "filename.htm" 2.2 - 把它设为可见 objIE.Visible true ...
this is an Example:这是一个例子:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.