CodeItBetter Programming Another VB Programming Blog

How to create MS Word Document from your Program

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
'MS Office - How to create MS Word Document from your Program

'Add a Command Button to your form and set reference to Microsoft Word xx.x Object Library

Private Sub Command1_Click()
    Dim objWord As New Word.Application
    objWord.Visible = False
    objWord.Documents.Add
    objWord.Selection.TypeText "This is the text http://codeitbetter.com"
    objWord.Selection.WholeStory
    objWord.Selection.Font.Size = 50
    objWord.Documents.Save
    'To print the document
    'objWord.PrintOut
    Set objWord = Nothing
End Sub
Filed under: MS Office Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.