Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


setting font style for text output

Posted on 2003-03-11
Medium Priority
Last Modified: 2013-12-02
I am opening a text output file as follows:

Open "filename" For Output As #2

This is a notepad file. I now want to set the font style to "Courier". How ? The reason for this is the equal character spacing of the Courier font for columnar spacing.
Question by:gron

Expert Comment

ID: 8111634
Notepad does not understand any formatting.
You would be better with the RTF (Rich Text Format)
using a RichTextBox control.

Expert Comment

ID: 8111642


If you open the file as output, it means that you are writing to it. Then, you _can't_ set the font of the file: the file is only a set of characters!

The font that you see is the one you set up in your editor (e.g. Notepad).

If you mean that you want to open the file for _input_ and show it in your application, then simply set the "Font" property of the textbox, richtextbox, or whatever control you need.

Let me know more details if you need more info
LVL 22

Expert Comment

ID: 8111899
The only other choice is to output into a file with formatting that some application will understand.  Notepad does not understand formatting, but others do, such as a browsers, so you could write this:

strOutputText = txtOutputInfo.Text ' transfer message here

Open "filename.htm" For Output As #2

print #2, "<HTML>"
print #2, "<BODY>"
print #2, "<FONT FACE='Courier New'>"; strOutputText; "</FONT>"
print #2, "</BODY>"
print #2, "</HTML>"
close #2

Note that I used Courier New, which is a better choice than Courier.
Also note that I saved this as an html file (in the open statement) so that you can just double-click it and see it in your browser.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

LVL 16

Expert Comment

ID: 8111952
That's not a "notepad file". It is just plain text file that you COULD open with notepad.
If you need to change the font in Notepad, you have to change to the registry, open the file with Notepad and change to the registry again.
The key is located at:

The steps should be:
Save the current value
change it
open the file
restore the original value:
To change values to registry, see this link:
LVL 22

Accepted Solution

rspahitz earned 200 total points
ID: 8112039
I'm not positive, but I think the Notepad font change is only available starting with Windows 2000.  If you have an earlier system, I'm pretty sure you're stuck with Courier New anyway.

Another possibility is to simply write yourself a simple app that "simulates" notepad.  Just add a textbox to a form, maximize it in the Resize event procedure, and add a menu with a few commands to load, save, cut/copy/paste.

Yet another possibility is to grab an older version of Notepad from, say Win95, rename it to something like Notepad95.exe and deliver that with your app and call it on demand.

Author Comment

ID: 8112423
Sorry folks, the question was badly worded. After I create the output file, I then open it with a

Shell "notepad filename", 3

It's at this point that I would have wished to set the fontname.
rspahitz: yes, you're right, I'm working with W2K. W98 also has a font name option under "Edit - Set Font", but I don't know about the others.
Ritchie: Good idea, but it's in a different registry location on W98, and maybe others OS.
So I'm going with the flow here, and re-designing the app. Thanks all.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question