VBScript to Change the font

Hi,

  I have a text file that has some formatted content.
I want to change the font of this text file using vbscript.
Can someone kindly help with the sample code?
pvsbandiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
A plain text file has no font information. Please explain your context.
0
pvsbandiAuthor Commented:
Thanks!
It is a text file. When trying to print, the text is wrapping because of the font size. So, the idea is to decrease the font and be able to display the information without wrapping.
0
ste5anSenior DeveloperCommented:
How do you print it?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

pvsbandiAuthor Commented:
it's the users who print it manually. Letter -> Portrait
I can ask them to change the layout but not everyone knows to do it.
0
ste5anSenior DeveloperCommented:
Well, let them use Wordpad or Word.. As long as they print it manually, you cannot do much.
0
pvsbandiAuthor Commented:
i need to somehow change the text content so it doesn't wrap in certain places
0
ste5anSenior DeveloperCommented:
Then you need to reformat it. Insert line breaks after 72 characters.
0
pvsbandiAuthor Commented:
any example code you can help me with?
0
ste5anSenior DeveloperCommented:
E.g. something like

Option Explicit

Const fsoForReading = 1
Const fsoForWriting = 2

Function LoadStringFromFile(filename)
    Dim fso, f
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.OpenTextFile(filename, fsoForReading)
    LoadStringFromFile = f.ReadAll
    f.Close
End Function

Sub SaveStringToFile(filename, text)
    Dim fso, f
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.OpenTextFile(filename, fsoForWriting)
    f.Write text
    f.Close
End Sub

Sub ReformatString(text)

    Dim count, result
	
    text = Replace(text, vbCrLf & vbCrLf, "@#|<>")
	For count = 1 to Len(text)
	    result = result & Mid(text, count, 1)
		If count mod 76 = 0 Then
		   result = result & vbCrLf
		End If
	Next count
	
	ReformatString = Replace(result, "@#|<>", vbCrLf & vbCrLf)
	
End Sub

SaveStringToFile "f.txt", ReformatString(LoadStringFromFile("f.txt"))

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pvsbandiAuthor Commented:
Thank you!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.