I have a php file on our intranet and I need to create a script to:
- load another php file (on the intranet too)
- save it as local mht file
- open the mht with Excel
- 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)