Word 2003 SaveAs wdFormatDOSText bug

C

cp

When I run a macro, such as this:

ActiveDocument.SaveAs FileName:="c:\temp\testdoc.txt",
FileFormat:=wdFormatDOSText

It is not removing all of the non-DOS characters.

When I do it interactively, it works, but it prompts me with Security
warnings. It appears interactively, it's setting the FileFormat=100 instead
of wdFormatDOSText, which = 4. (Obtained by recording a macro)

I need to be able to do this without security warnings and without non-DOS
characters. Anyone know of a fix?

Thanks for any help.

-cp
 
K

Klaus Linke

Hi cp,

How did you determine that Word uses FileFormat=100 when doing the SaveAs in the user interface?

DOS isn't one code page. There used to be different code pages for different brands of computers and OS, countries...

You'd probably need to specify the code page you want in the Encoding parameter -- say 850 for the CP850 used a lot in US MS-DOS (as far as I remember).

If you don't know which code page you need:
What characters are giving you problems? (what did they look like in Word before, and what happened to them)
What do you want to do with the resulting text file?

Regards,
Klaus
 
C

cp

Thanks Klaus,

I added the AllowSubstitutions=TRUE parameter to the SaveAs method and it
converted or removed characters like non-breaking space that were causing
problems. That should correct our problem.

To determine that Word was using FileFormat=100, I just recorded a macro
doing a saveas and that's what it put in the Macro.

Thanks again,
-cp


Hi cp,

How did you determine that Word uses FileFormat=100 when doing the SaveAs in
the user interface?

DOS isn't one code page. There used to be different code pages for different
brands of computers and OS, countries...

You'd probably need to specify the code page you want in the Encoding
parameter -- say 850 for the CP850 used a lot in US MS-DOS (as far as I
remember).

If you don't know which code page you need:
What characters are giving you problems? (what did they look like in Word
before, and what happened to them)
What do you want to do with the resulting text file?

Regards,
Klaus
 
K

Klaus Linke

cp said:
I added the AllowSubstitutions=TRUE parameter to the SaveAs method and it
converted or removed characters like non-breaking space that were causing
problems. That should correct our problem.

The non-breaking space was available in the DOS code pages I remember (at &xFF/255). I hate it when Word's export filters remove or change stuff uncontrollably, but it seems it helped you here ;-)
To determine that Word was using FileFormat=100, I just recorded a macro
doing a saveas and that's what it put in the Macro.

I didn't get that, but Word probably chooses a sensible code page from your Windows regional/language settings or the like.

Regards,
Klaus
 
C

cp

Klaus,

Well, I may have spoken too soon. Now we get ? wherever a non-breaking
space was, whereas in previous versions of Word we got a space. I posted
another thread, Saveas wdFormatText problem (Word 2003), with more detail to
the microsoft.public.word.conversions group to see if anyone has a
workaround.

Thanks again,
-c


cp said:
I added the AllowSubstitutions=TRUE parameter to the SaveAs method and it
converted or removed characters like non-breaking space that were causing
problems. That should correct our problem.

The non-breaking space was available in the DOS code pages I remember (at
&xFF/255). I hate it when Word's export filters remove or change stuff
uncontrollably, but it seems it helped you here ;-)
To determine that Word was using FileFormat=100, I just recorded a macro
doing a saveas and that's what it put in the Macro.

I didn't get that, but Word probably chooses a sensible code page from your
Windows regional/language settings or the like.

Regards,
Klaus
 
K

Klaus Linke

Hi cp,

Looks like a bug in the text converter to me, if you choose "US ASCII" as the text filter.
Don't know which code page that is, but all US code pages I checked have ^255 for the non-breaking space.

Can you use "OEM USA" instead? it doesn't have that problem, and converts the non-breaking space properly into ^255.

Or if you really don't mind to get rid of the non-breaking spaces, you could search replace them (^s in "Find what") with spaces before saving.

Regards,
Klaus
 

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