dongzhong8834 2017-12-12 15:29
浏览 51

hta Internet Explorer应用程序

I have a php file on our intranet and I need to create a script to:

  1. load another php file (on the intranet too)
  2. save it as local mht file
  3. open the mht with Excel
  4. display Excel with the mht

(this is enforced by my hierarchy)

I create a hta file and load it from javascript in the first php. This work well except in windows 10, (I use IE , not Edge)

  • then using the IE object and changing his visible state to false, IE still appears,
  • then waiting using then .busy function, the loop never finish
  • Strange: if I change the url ( for example, using http://google.com) the script work well.

Summary of the hta file

<script language=vbs>
Dim WS, FS, URL, Path, Title
Sub SaveAsMhtml()
    Set FS = CreateObject("Scripting.FileSystemObject")
    On Error Resume Next
' for example
    URL= "http://mysite/myphp.php?what=1"
'with this following url, all is OK
'URL="http://google.com"
    Title="test.mht"
    Path = "C:\temp\"
    If Not FS.FolderExists(Path) Then FS.CreateFolder Path
    set IE=CreateObject("InternetExplorer.Application")
    With IE
        .Navigate URL
' this line do nothing in W10
        .visible=false
' this do not work in w10 too
'       Do While .Busy: Loop
        ' create the mht
        With CreateObject("CDO.Message")
            On Error Resume Next
            .CreateMHTMLBody(URL)
            FS.CreateTextFile Path & Title 
            .BodyPart.GetStream.SaveToFile Path & Title , 2
        End With
' this line create an execution error in w10
        .Quit
    End With
    Set objExcel =CreateObject("Excel.Application")
    Set objWorkbook = objExcel.Workbooks.Open(Path & Title)
    objExcel.visible=true
    window.close
End Sub
</script>

So where is my error ? Or is it another solution to solve my initial need ? (without the hta if possible)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP