1

Im using this vbscript code to save a page displayed in IE9 as a mht file. To run it, place it in the favourites bar and then click it. The problem is it will save the the page but the filename will end in ## for example homepage##.mht. Does anyone see how to remove that ## on the filename? I see that it is used in the logic to do the task but it's annoying lol.

Thanks.

Set ies=CreateObject("Shell.Application").Windows()
For Each ie In ies
  If ie.ReadyState=4 Then If TypeName(ie.Document)="HTMLDocument" Then If ie.Document.hasFocus() Then Exit For
Next
If IsEmpty(ie) Then
For Each ie In ies
If ie.ReadyState<>4 Then
ElseIf TypeName(ie.Document)="HTMLDocument" Then
ie.Document.focus
If ie.Document.hasFocus() Then Exit For
End If
Next
End If
If IsEmpty(ie) Then
MsgBox "Not Found"
WScript.Quit
End If
href=ie.locationURL
Set a=ie.Document.createElement("a")
a.href=href
a.hash="##"
ie.Document.parentWindow.setTimeout "location.replace """ & a.href & """",0,"vbscript"
Do While ie.Document.parentWindow.location.hash<>"##"
WScript.Sleep 100
Loop
ie.ExecWB 4,1
ie.Document.parentWindow.location.replace href
omega
  • 40,311
  • 81
  • 251
  • 474

0 Answers0