OLE Automation: Printing .rtf documents using MS Word

OLE Automation: Printing .rtf documents using MS Word

Post by Davi » Thu, 05 Oct 2000 04:00:00



I am interested in creating a simple VB app. that will read in a file
path (or directory) and print all of the .rtf documents therein.  I
believe that I can simply create a Word object and using the
.Application property, use the .PrintOut method to do this but I have
not been successful.  Any help would be greatly appreciated.

Also, utlimately, I would like to be able to query the Registry to find
the registered app. for .rtf documents and use that to print them.  For
now, I will be satisfied assuming that MS Word is installed.

Thanks.


David

 
 
 

1. Problems in VB code on combining RTF files using Marco in MS word

My Macro in MS word keeps getting me minor problem on the final
document(in .rtf)

For instance,

I created 5 rtf files from SAS. I'm combining them into
one RTF file using a VB code.
But the problem is that page numbers located Header in each RTF file
get shifted to
the next line. In original RTF files, Header is as below

___________________________________________________________
Table
Title
Page 1 of 2

But after I run this code, page number moved below the table title as
below

___________________________________________________________
Table Title
Page 1 of 2

Can anyone see the problem from the following code?

--------------VB Code Starts
here---------------------------------------
Sub Combine_files()

filepath = InputBox("Name of directory with rtf files, with no ending
slash! (e.g. c:\define\nda)")
Documents(1).Close SaveChanges:=wdDoNotSaveChanges
   Documents.Add DocumentType:=wdNewBlankDocument

Application.ScreenUpdating = False

Set fs = Application.FileSearch
   With fs
       .LookIn = filepath
       .FileName = "*.RTF"
       If .Execute = 0 Then
           MsgBox "There were no files found."
       End If
   End With

   For i = 1 To fs.FoundFiles.Count

       Documents.Open FileName:=fs.FoundFiles(i), Visible:=True
       Selection.HomeKey Unit:=wdStory
       Selection.EndKey Unit:=wdStory, Extend:=wdExtend
       Selection.Copy

       Documents(fs.FoundFiles(i)).Close
SaveChanges:=wdDoNotSaveChanges
       Selection.Paste

       If i < fs.FoundFiles.Count Then
           Selection.InsertBreak Type:=wdSectionBreakNextPage
       End If

   Next i

   For Each s In ActiveDocument.Sections
       With s.Headers(wdHeaderFooterPrimary).PageNumbers
           .RestartNumberingAtSection = True
           .StartingNumber = 1
       End With
   Next s

   Application.ScreenUpdating = True

   ActiveDocument.SaveAs FileName:=filepath & "\all.rtf",
fileformat:=wdFormatRTF

   MsgBox "I'm Done!"

   End Sub

-----------------VB Code Ends
here-------------------------------------------

2. Conversion of AutoLISP programs

3. Print MS-Word-Document on the client-machine

4. Retrieving (Autonumber)identity field after using trigger

5. Word/RTF Document

6. Any other newsgroup of Spectrum fans?

7. how can i convert a word document to RTF File through programmatically

8. GTE Bronze+

9. Word/RTF Document

10. easy way to create an RTF file from a Print document?

11. create a word document using asp.net and word application

12. Alternatives to using Word.Document for generating documents