Save Word Doc as ASCII Text and set line width?

D

djconner

I have a VBA/Microsoft Access program that generates a document in
Word 2000. My new requirement is that I need to then save the
document in ASCII text with a maximum line width of 69 characters.

I think I have the first part covered, and in terms of formatting it's
fairly simple already, but I'm not sure how to go about setting that
69-character line width.

A side issue, in case anybody knows... Can accented characters be
used in an ASCII text document, and if so, how? Specifically, this
character: É as used in the capitalized word "ATTACHÉ". Currently
when doing a SaveAs to wdFormatDOSTextLineBreaks, that character turns
into a garbage character.
 
J

Jonathan West

I have a VBA/Microsoft Access program that generates a document in
Word 2000. My new requirement is that I need to then save the
document in ASCII text with a maximum line width of 69 characters.

I think I have the first part covered, and in terms of formatting it's
fairly simple already, but I'm not sure how to go about setting that
69-character line width.

A side issue, in case anybody knows... Can accented characters be
used in an ASCII text document, and if so, how? Specifically, this
character: É as used in the capitalized word "ATTACHÉ". Currently
when doing a SaveAs to wdFormatDOSTextLineBreaks, that character turns
into a garbage character.


Hi djconnor

The key to setting the line length to 69 characters is to proceed as follows
before you save the document.

1. Format all text in the document using a fixed-width font such as Courier
New and with a common font size

2. Adjust the margins so that the line width accommodates no more than 69
characters

To get the accented E to appear OK in the text file, save as
wdFormatTextLineBreaks, not as wdFormatDOSTextLineBreaks.



--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
D

djconner

Thanks, this looks like it'll work.
On the formatting, though, is wdFormatTextLineBreaks consistent with
ASCII? The intended goal is to cut and paste the Word document into
some legacy system I'm unfamiliar with, but that's said to require
ASCII. My guess is that means it probably wouldn't understand the
accented E input?
 
J

Jonathan West

djconner said:
Thanks, this looks like it'll work.
On the formatting, though, is wdFormatTextLineBreaks consistent with
ASCII? The intended goal is to cut and paste the Word document into
some legacy system I'm unfamiliar with, but that's said to require
ASCII. My guess is that means it probably wouldn't understand the
accented E input?

Strictly speaking, there is no accented e in the ASCII character set. It is
an ANSI character that is in the character range 128-255, often described
(inaccurately) as 8-bit ASCII, or upper range ASCII.

You'll have to test whether your legacy system will be able to cope. It
probably will, but if it can't, you'll have to map all upper-ASCII
characters to strict ASCII equivalents - e.g. mapping an accented e to a
plain e.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
S

Steve Rindsberg

Djconner said:
Thanks, this looks like it'll work.
On the formatting, though, is wdFormatTextLineBreaks consistent with
ASCII? The intended goal is to cut and paste the Word document into
some legacy system I'm unfamiliar with, but that's said to require
ASCII. My guess is that means it probably wouldn't understand the
accented E input?

The so-called "high-ascii" characters (those > 127) may be mapped to different
characters depending on your OS and codepage, but as long as you're using a
system based on standard roman characters (ie, not asian, cyrillic, or some
other script) you'll probably be ok. Unless the legacy system only accepts
7-bit ascii.

Obviously, the only way to be certain is to test.
 
D

djconner

Obviously, the only way to be certain is to test.

Yeah, I definitely need to get a hold of the target program to be
sure.

One thing, though, I've already noticed, is that
wdFormatTextLineBreaks (or wdFormatDOSTextLineBreaks) isn't doing
exactly what I expected. When opening the resulting text file in,
e.g., Notepad, a long paragraph becomes one long line, and isn't
broken into 69-character lines.

Is there any way I can get the text file to save "as displayed" under
Word's page settings?
 
D

djconner

Whoops, disregard the previous message, I think I just got confused
about something. If I do a Select All, copy and paste directly from
Word, I get the long lines, but if I open up the TXT file directly
with Notepad, it's formatted in 69-character lines, as intended.

I'm slightly curious about why *that* is, but it's not terribly
important.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top