|Knowing that vbscript cannot create Msgbox with scrollbars I have been trying to get round this by using HTA but with only partial success. The script I have is not mine but I have modified it slightly. The problem is that although it does produce a window with scrollbars text is displayed in the window as a continuous string with all formatting eliminated. |
I have tried to resolve this using ReadLine rather than ReadAll but it makes no difference yet I was sure that ReadLine automatically incorporates a VBCrLf at the end of every line. The other oddity is that wscript.echo does not work. An error is produced requiring an "object". When that is provided, the subsequent error is that Echo is not supported. I am guessing here that this is down this being run as an HTA file not a vbscript one.
If anyone can enlighten me on that and knows how to retain the original file text formatting I would be grateful if they could let me know.
ID = "oHTA"
APPLICATIONNAME = "Read Text Files with HTA"
BORDER = "thick"
CAPTION = "yes"
ICON = "app.ico"
SHOWINTASKBAR = "yes"
SINGLEINSTANCE = "yes"
SYSMENU = "yes"
WINDOWSTATE = "normal"
SCROLL = "yes"
SCROLLFLAT = "yes"
VERSION = "1.0">
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set oFS = CreateObject("Scripting.FileSystemObject")
If oFS.fileExists(fName.value) Then
Set oFile = oFS.OpenTextFile(fName.value, ForReading)
sContents = oFile.ReadAll
' ReadLine does not seem to work
'Do Until oFile.atEndOfStream
'sContents = oFile.ReadLine
MsgBox "File not found: " & fName.value
<BODY scroll="yes" style=
border:0px; padding:0px; margin:0px">
<table cellspacing=0 cellpadding=0
border=0 width=100% height=100%>
File name: <INPUT TYPE="text" Size=50 Name="fName">
<BUTTON style="border:1px outset;width:100px" onClick="ReadFile" >
<div id="txtbox" style=
border: 1px inset;
font: 8pt Arial; width:100%;