Opening ASCII Files

B

Brenda A. Reid

Word XP

I have a macro in WordPerfect that opens an ASCII file so that I can then
convert to a merge file. The perfect script is:

FileOpen (Filename:"c:\temp\dunning.txt"; Format:ASCIIStandard!)

Word will open the ASCII file but is not displaying it right. Was wondering
if someone could convert the above to VBA for me . . .

Tks . . .
 
S

Shauna Kelly

Hi Brenda

Try something like this:

Dim oDoc as Word.Document

Set oDoc = Documents.Open _
(FileName:="plaintextfile.txt", _
Format:=wdOpenFormatText )

'you can now do stuff with the oDoc object, eg...
msgbox oDoc.name

Look up VBA Help under Open to get specific information about the Format
parameter.

By the way, the macro recorder does quite a good job of pointing you to the
objects, methods and properties you need. But you often need to clean up
after it. For info on that, see
How to Modify a Recorded Macro
http://word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 

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