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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

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.

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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

762 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