Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTA Output Font Color 1

Status
Not open for further replies.

Brycspain

IS-IT--Management
Mar 9, 2006
150
US
I've been messing around with HTA's lately and was trying some font manipulation within the vbscript part of my code however, I'm having a hard time understanding the syntax of it. I have some if then statements with coresponding messages mixed with variables and text fields. For instance, I would like the output of this line to come out green on my script:
Code:
strHTML = strHTML & disUser & " folder was renamed on " & folPath  & "<br>"

I read you could use the following code to color your output...I tried it several ways and could't get it to work:

Code:
<font color="red" face="Times New Roman" size="3">Your text goes here</font>

I thought I would try easier font styles like bold around a variable like this and it works although I still don't understand how to surround the entire line with the code:
Code:
"<b>" & variable & "</b>"

If the above works, why doesn't the code below work? I thought it was because of the double quotes so I tried char(34) with no luck.
Code:
"<font color="red" face="Times New Roman" size="3">" & variable & "</font>"

Here is the entire HTA:
Code:
<head>
<title>HTA Test</title>
<HTA:APPLICATION 
     APPLICATIONNAME="Test Folder Rename"
     SCROLL="yes"
     SINGLEINSTANCE="yes"
>
</head>

<script language="VBScript">

sub renamefolders
disuser = "doej"
Set objFSO = CreateObject("Scripting.FileSystemObject")

arrPath = Array("\\houfiler\tsprofiles$\", "\\swn.com\remotedata\swn-di\", "\\houfiler\rootdrv$\", _
                "\\fayfiler\rootdrv$\", "\\fayfiler\nrtsprofile$\", "\\houfiler\home$\", _
                "\\fayfiler\home$\")

For Each folPath In arrPath
If objFSO.FolderExists(folPath & disuser) Then
objFSO.MoveFolder folPath & disUser , folPath & "_" & disUser
   If Err.Number = 0 Then
   [b]strHTML = strHTML & disUser & " folder was renamed on " & folPath  & "<br>"[/b]
   Else
   [b]strHTML = strHTML & "Move folder error #: " & Err.Number & " Err Desc: " & Err.Description & "<br>"[/b]
   End If
Else
[b]strHTML = strHTML & folPath & " didn't exist so it wasn't moved." & "<br>"[/b]
End If
err.clear
Next
DataArea.InnerHTML = strHTML 
end sub

</script>
<body>
<input type="button" value="Rename Folders" name="run_button" onClick="renamefolders">
<p>
<span id = "DataArea"></span>
</body>
 
You can try

Code:
Dim strTemp : strTemp = "Some text to format."
DataArea.InnerHTML = "<font color='red' face='Times New Roman' size='3'>" & strTemp & "</font>"

or

Code:
Dim strTemp : strTemp = "Some text to format."
DataArea.InnerHTML = "<font color=""red"" face=""Times New Roman"" size=""3"">" & strTemp & "</font>"

or use CSS style sheets instead

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Thanks again DM...This line worked great:

Code:
strHTML = strHTML & disUser & " folder was renamed on " & folPath & "<br>"
   strHTML = "<font color=""green"" face=""Times New Roman"" size=""3"">" & strHTML & "</font>"

Do you know any good tutorials for HTA's besides the scripting guys one?
 
Thanks PHV, that was the one I already knew about. I'm the scripting son =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top