Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleConvert a .rtf or .txt file into a .doc file
DescriptionThis example shows how to convert a .rtf or .txt file into a .doc file in Visual Basic 6.
Keywordsdocument, word, rtf, txt, doc, convert file
CategoriesOffice, Files and Directories
 
Use Word as a server. Load the file and save it in its new format.

The ConvertToDoc subroutine opens a file and saves it as a .doc file.

 
' Open a file and save it as a .doc file.
Private Sub ConvertToDoc(ByVal in_file As String, ByVal _
    out_file As String)
Const FORMAT_DOC As Integer = 0

Dim word_server As Object ' Word.Application

    Set word_server = CreateObject("Word.Application")

    ' Open the input file.
    word_server.Documents.Open _
        FileName:=in_file, _
        ReadOnly:=False, _
        AddToRecentFiles:=False

    ' Save the output file.
    word_server.ActiveDocument.SaveAs _
        FileName:=out_file, _
        FileFormat:=FORMAT_DOC, _
        LockComments:=False, _
        AddToRecentFiles:=True

    ' Exit the server without prompting.
    word_server.ActiveDocument.Close False
End Sub
 
 
Copyright © 1997-2006 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated