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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

outputting to text file with vba - setting font

Status
Not open for further replies.

arpeggione

Programmer
Nov 23, 2005
99
US
Hi: I am using the following code which creates a text file with the Courier New font:

Print #intFile, strTest & strMID & strAssy & strDescription & strQty & strTest1 & strUOM; "<FONT=Courier New>"

However...I get this output - columns are lined up but I get the fot text at the end (after EA)...

9995561 XFMR CURRENT WOUND TYPE 1 EA<FONT=Courier New>
9995564 HUB 1/2" CONDUIT (MYERS HUB) 1 EA<FONT=Courier New>
9997028 CONNECTOR WT COMP NUT/RUB GROM 1 EA<FONT=Courier New>

any ideas how I can get the font to be Courier New, get the columns to line up, but NOT get the text between < >?

thank you!

Karen
 


The font setting is irrelevant.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Skip: No, actually it isn't. With the "Courier New" font - the columns line up in the text file (we don't want to go via Excel - straight to text instead). And...it does work.

thank you,
Karen
 


In specifying the output, it is irrelevant.

In your word processor is wher you need to assign a FIXED PITCH font.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Karen,
Thanks for creating a new thread for the new question. I think any issue would be with "Text file goes into Microstation". I'm not sure why you think you need to add any font information into the file.

What happens if you simply remove the "<FONT=Courier New>"?



Duane
Hook'D on Access
MS Access MVP
 
When I add the "<FONT=Courier New>", the columns line up perfectly (although it doesn't look like it in my post). If I take it out, the font is back to Arial and the columns don't line up. I want to always assure that the font is Courier New, no matter who uses it.

thank you,

Karen

 


the font is back to Arial
THAT is a function of the application that you opened the file in -- NOT the file itself.

YOU can change the Font to Courier in that application.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 

The question here is - what do you use to open the text file?
Notepad would be my first choice. Set Notepad's font to Courier and any file opened in Notepad will use this Font.

Have fun.

---- Andy
 
I'm using Notepad indeed - but the default font is Arial....I want to guarantee with my vba (so the user doesn't have to do anything) that the default font is Courier New...
thank you,
Karen
 
Karen,
Does a user open the file in Notepad or does it get imported into another application?

I don't think Access is the correct application to be setting the default font of another application. I expect this could be scripted in a way that modifies the users' registry which is a dangerous process.

Duane
Hook'D on Access
MS Access MVP
 
Duane: Ok...I wrote incorrectly. You are responding exactly to what I wrote. I don't want to change the user registry or default font - just set the font for the text in the Notepad file as Courier New. The code I have at the beginning of this thread works - but with a hitch...thank you, Karen
 
the vba code in Access opens a file in Notepad (simplest version - using the Transfertext feature)

thank you for your persistance...it is hard to communicate in writing and without seeing what I am doing...

the vba code:

Print #intFile, strTest & strMID & strAssy & strDescription & strQty & strTest1 & strUOM; "<FONT=Courier New>"


karen
 
Microstation was a diversion from the issue. It isn't relevant. The text file gets imported into MS, and someone was suggesting a COMPLETELY different way to do what I'm doing. However, I'm committed to creating a text file with even columns from Access...almost there.
 
If your intention is to simply create the file for users to review, consider creating the file with an HTM extension and wrap all the text within <PRE> </PRE> tags. This should open in a web browser

Duane
Hook'D on Access
MS Access MVP
 
Thank you for all of the comments. I think I'm going to go with what I've got (and just have users change the font in the text file to Courier New if they need to). This can be closed out.

It was all very helpful!

Karen
 
I think what the OP is not understanding here is that a "text" file (i.e. ASCII file) doesn't have a "font", it is just storing the characters in ASCII code. Each character is represented by a number, "a" is 97, "b" is 98, etc. Special characters, such as Tab or Linefeed also have a number (9 and 10 respectively). There's nothing in ASCII that let's you say "when someone opens this file please present this in Courier font". That choice is entirely up to whichever program you use to open the file (Notepad, Word, Excel, etc.).

What you are seeing in Notepad is a presentation of the ASCII coded characters after they were converted from numbers to characters. The font is just whatever happens to be your default font for that application.

If you rely on your text to be presented in a certain font, you need to set up your User Interface to display the characters in that font. So for example, you could read in the characters from the file and place them in a text box which is set to display in that font.

Here's a link to an ASCII chart to show what numbers each character is represented by.

 
Thank you for your input Joe.....We're all set for now, but I may try this in the future. Interesting idea...Karen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top