Word 97: open MS-DOS-Text programmatically 
Author Message
 Word 97: open MS-DOS-Text programmatically

Hello,

I'm trying to write a macro which opens an MS-DOS text file, converts
all the text to a table and saves this as word document.

The problem: there doesn't seem to be a constant wdOpenFormatDOSText or
the like, so I don't find a way to convert the file correctly from ASCII
to ANSI. Setting ConfirmConversions to True works, but needs user
interaction, which isn't an option.

As the file contains german text, wdOpenFormatText gives false results.

Must be an error in Word, because wdFormatDOSText exists, saving as DOS
text works perfectly.

Can anybody help?

Thank you,
Koczian

--
----
Dr. Sibylle Koczian
Universitaetsbibliothek , Abt. Naturwiss.
D-86135 Augsburg

Tel.: (0821) 598-2400, Fax : (0821) 598-2410



Fri, 19 Sep 2003 19:29:29 GMT  
 Word 97: open MS-DOS-Text programmatically
Can you use the Open and Line Input to do direct reads? That should work if
you have a predictably-formatted text file.



Quote:
> Hello,

> I'm trying to write a macro which opens an MS-DOS text file, converts
> all the text to a table and saves this as word document.

> The problem: there doesn't seem to be a constant wdOpenFormatDOSText or
> the like, so I don't find a way to convert the file correctly from ASCII
> to ANSI. Setting ConfirmConversions to True works, but needs user
> interaction, which isn't an option.

> As the file contains german text, wdOpenFormatText gives false results.

> Must be an error in Word, because wdFormatDOSText exists, saving as DOS
> text works perfectly.

> Can anybody help?

> Thank you,
> Koczian

> --
> ----
> Dr. Sibylle Koczian
> Universitaetsbibliothek , Abt. Naturwiss.
> D-86135 Augsburg

> Tel.: (0821) 598-2400, Fax : (0821) 598-2410




Sun, 21 Sep 2003 03:47:56 GMT  
 Word 97: open MS-DOS-Text programmatically
Hi Sibylle

You could try this:

Sub TestToOpen()
Dim oDoc As Document

Documents.Open _
    FileName:="c:\anypath\anyfile.txt"

Set oDoc = ActiveDocument
With oDoc
    .Range.ConvertToTable   'look up help for more info
    .SaveAs _
        FileName:="anything.doc", _
        Fileformat:=wdFormatDocument
    .Close SaveChanges:=wdDoNotSaveChanges
End With
End Sub

--
/Anna Bohman
Bra Utbildning AB, Sweden

-------------------------------------------------------------------------



Quote:
> Hello,

> I'm trying to write a macro which opens an MS-DOS text file, converts
> all the text to a table and saves this as word document.

> The problem: there doesn't seem to be a constant wdOpenFormatDOSText or
> the like, so I don't find a way to convert the file correctly from ASCII
> to ANSI. Setting ConfirmConversions to True works, but needs user
> interaction, which isn't an option.

> As the file contains german text, wdOpenFormatText gives false results.

> Must be an error in Word, because wdFormatDOSText exists, saving as DOS
> text works perfectly.

> Can anybody help?

> Thank you,
> Koczian

> --
> ----
> Dr. Sibylle Koczian
> Universitaetsbibliothek , Abt. Naturwiss.
> D-86135 Augsburg

> Tel.: (0821) 598-2400, Fax : (0821) 598-2410




Sun, 21 Sep 2003 06:27:35 GMT  
 Word 97: open MS-DOS-Text programmatically
Quote:

> Hi Sibylle

> You could try this:

> Sub TestToOpen()
> Dim oDoc As Document

> Documents.Open _
>     FileName:="c:\anypath\anyfile.txt"

That opens the file as _text_ file (ANSI), but it must be opened as
_MS-DOS_ text file, that's the problem!

Quote:
> Set oDoc = ActiveDocument
> With oDoc
>     .Range.ConvertToTable   'look up help for more info
>     .SaveAs _
>         FileName:="anything.doc", _
>         Fileformat:=wdFormatDocument
>     .Close SaveChanges:=wdDoNotSaveChanges
> End With
> End Sub

> > I'm trying to write a macro which opens an MS-DOS text file, converts
> > all the text to a table and saves this as word document.

> > The problem: there doesn't seem to be a constant wdOpenFormatDOSText or
> > the like, so I don't find a way to convert the file correctly from ASCII
> > to ANSI. Setting ConfirmConversions to True works, but needs user
> > interaction, which isn't an option.

> > As the file contains german text, wdOpenFormatText gives false results.

> > Must be an error in Word, because wdFormatDOSText exists, saving as DOS
> > text works perfectly.

--
----
Dr. Sibylle Koczian
Universitaetsbibliothek , Abt. Naturwiss.
D-86135 Augsburg

Tel.: (0821) 598-2400, Fax : (0821) 598-2410



Sun, 21 Sep 2003 16:06:36 GMT  
 Word 97: open MS-DOS-Text programmatically
Quote:

> Can you use the Open and Line Input to do direct reads? That should work if
> you have a predictably-formatted text file.

I'll try, thank you for the tip.

--
----
Dr. Sibylle Koczian
Universitaetsbibliothek , Abt. Naturwiss.
D-86135 Augsburg

Tel.: (0821) 598-2400, Fax : (0821) 598-2410



Sun, 21 Sep 2003 16:08:13 GMT  
 Word 97: open MS-DOS-Text programmatically
Sibylle

This makes me very curious. Why do you have to open it as a MS-Dos file?

/Anna


Quote:

> > Hi Sibylle

> > You could try this:

> > Sub TestToOpen()
> > Dim oDoc As Document

> > Documents.Open _
> >     FileName:="c:\anypath\anyfile.txt"

> That opens the file as _text_ file (ANSI), but it must be opened as
> _MS-DOS_ text file, that's the problem!

> > Set oDoc = ActiveDocument
> > With oDoc
> >     .Range.ConvertToTable   'look up help for more info
> >     .SaveAs _
> >         FileName:="anything.doc", _
> >         Fileformat:=wdFormatDocument
> >     .Close SaveChanges:=wdDoNotSaveChanges
> > End With
> > End Sub

> > > I'm trying to write a macro which opens an MS-DOS text file, converts
> > > all the text to a table and saves this as word document.

> > > The problem: there doesn't seem to be a constant wdOpenFormatDOSText
or
> > > the like, so I don't find a way to convert the file correctly from
ASCII
> > > to ANSI. Setting ConfirmConversions to True works, but needs user
> > > interaction, which isn't an option.

> > > As the file contains german text, wdOpenFormatText gives false
results.

> > > Must be an error in Word, because wdFormatDOSText exists, saving as
DOS
> > > text works perfectly.

> --
> ----
> Dr. Sibylle Koczian
> Universitaetsbibliothek , Abt. Naturwiss.
> D-86135 Augsburg

> Tel.: (0821) 598-2400, Fax : (0821) 598-2410




Sun, 21 Sep 2003 17:42:34 GMT  
 Word 97: open MS-DOS-Text programmatically
Quote:

> Can you use the Open and Line Input to do direct reads? That should work if
> you have a predictably-formatted text file.

Tried it - doesn't convert from ASCII to ANSI (and why should it,
anyway?).

I think I'll try Excel, which _seems_ to have the right file format
constants for the open method.

Thanks,
Koczian

--
----
Dr. Sibylle Koczian
Universitaetsbibliothek , Abt. Naturwiss.
D-86135 Augsburg

Tel.: (0821) 598-2400, Fax : (0821) 598-2410



Mon, 22 Sep 2003 20:32:39 GMT  
 Word 97: open MS-DOS-Text programmatically
Anna,

Quote:

> Sibylle

> This makes me very curious. Why do you have to open it as a MS-Dos file?

Because it's produced by a MS-DOS application, so it's ASCII text and it
does contain characters above ASCII 127. If I open it as text file,
those characters come out wrong.

And I still cannot understand why I can open a MS-DOS file
interactively, save it as MS-DOS text interactively or programmatically,
but can't open it programmatically.

Sibylle

--
----
Dr. Sibylle Koczian
Universitaetsbibliothek , Abt. Naturwiss.
D-86135 Augsburg

Tel.: (0821) 598-2400, Fax : (0821) 598-2410



Mon, 22 Sep 2003 21:19:24 GMT  
 Word 97: open MS-DOS-Text programmatically

Quote:
> Because it's produced by a MS-DOS application, so it's ASCII text and it
> does contain characters above ASCII 127. If I open it as text file,
> those characters come out wrong.

Do the same characters come out correctly when you open the file manually?
What font does Word assign when you do this?


Tue, 23 Sep 2003 03:20:19 GMT  
 Word 97: open MS-DOS-Text programmatically
Sibylle

Feel free to mail me an MS-DOS file with a record or two in it. We have
plenty of characters above 127 in our language ?, ?, ? and I'ld like to
learn what the problem is.




Quote:
> Anna,


> > Sibylle

> > This makes me very curious. Why do you have to open it as a MS-Dos file?

> Because it's produced by a MS-DOS application, so it's ASCII text and it
> does contain characters above ASCII 127. If I open it as text file,
> those characters come out wrong.

> And I still cannot understand why I can open a MS-DOS file
> interactively, save it as MS-DOS text interactively or programmatically,
> but can't open it programmatically.

> Sibylle

> --
> ----
> Dr. Sibylle Koczian
> Universitaetsbibliothek , Abt. Naturwiss.
> D-86135 Augsburg

> Tel.: (0821) 598-2400, Fax : (0821) 598-2410




Tue, 23 Sep 2003 22:18:05 GMT  
 Word 97: open MS-DOS-Text programmatically

Quote:

> Do the same characters come out correctly when you open the file manually?
> What font does Word assign when you do this?

Yes, they do, if I've enabled the option "Confirm conversions", and if I
choose "MS-DOS Text" in the resulting dialog. The font is the standard
font of the document template I'm using (usually Times Roman, but
Courier new or Arial works just as well).

And that should work in a macro, with an appropriate wdOpenFormat...
constant - and there is none (in Word).

Meanwhile I've tried it in Excel: no problem at all, method OpenText,
parameter Origin:=xlMSDOS. As the file in question is used as a data
source for mail merge in Word, this works well.

So: solution found, but riddle not solved.

Thank you,
Sibylle

--
----
Dr. Sibylle Koczian
Universitaetsbibliothek , Abt. Naturwiss.
D-86135 Augsburg

Tel.: (0821) 598-2400, Fax : (0821) 598-2410



Sat, 27 Sep 2003 16:57:12 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. opening MS word from access 97

2. Elaborated problem on opening UserForm through MS-Word 97 VBA

3. MS Word 97 Open/Save dialog

4. Newbie to Word 97 VBA: Getting accurate word count programmatically

5. Access 97 connection with MS Word 97

6. Inserting MSchart 97 into MS Word 97

7. Open Word 97 from Access 97 HELP!!!

8. Sending text to Word 97 from Access 97 using OLE automation

9. Running DOS Scripts From MS Access 97

10. New to automation - a couple questions - MS Word 97

11. MS Graph 5 OLE Automation in Word from Access 97

12. Opening MS Project 98 plan from Excel 97 vb code

 

 
Powered by phpBB® Forum Software