The word object library is present in the references window and should be included to implement word document applications. The code below describes 3 examples. The first example creates a word document and inserts letters, paragraphs ans sets font sizes to them. The second example inserts text and checks spelling of the inserted text. The third example creates a word document in a given file location and inserts text in it.
Public obWrd As Word.Application
Private Sub Form_Load()
Dim obDc As Word.Document
Set obWrd = New Word.Application
obWrd.Visible = True
Set obDc = objWord.Documents.Add
objDc.Activate
obDc.ActiveWindow.Selection.InsertAfter "The Real Text"
obDc.ActiveWindow.Selection.InsertParagraphAfter
obDc.ActiveWindow.Selection.InsertAfter "The Big Text"
obDc.ActiveWindow.Selection.InsertParagraphAfter
obDc.ActiveWindow.Selection.Font.Bold = True
obDc.ActiveWindow.Selection.EndOf
obWrd.Quit False
Set obWrd = Nothing
End Sub
Public objword1 As Word.Application
Private Sub Form_Load()
Dim objDoc1 As Word.Document
Set objWord = New Word.Application
objword1.Visible = True
Set objDoc = objWord.Documents.Add
objDoc1.Activate
objDoc1.ActiveWindow.Selection.InsertAfter ("The Text")
On Error Resume Next
objDoc1.CheckSpelling
If Err Then
MsgBox Err.Description & Err.Number
End If
End Sub
Private Sub Form_Load()
Dim objWord As Object
Set objWord = CreateObject("Word.Basic")
objWord.filenew
objWord.startofdocument
objWord.FontSize 24
objWord.Insert "Big Letter Text"
objWord.FontSize 12
objWord.insertpara
objWord.Insert "Text with Smaller Font"
objWord.filesaveas "D:\test.doc"
'objWord.Close
Set objWord = Nothing
End Sub
Public obWrd As Word.Application
Private Sub Form_Load()
Dim obDc As Word.Document
Set obWrd = New Word.Application
obWrd.Visible = True
Set obDc = objWord.Documents.Add
objDc.Activate
obDc.ActiveWindow.Selection.InsertAfter "The Real Text"
obDc.ActiveWindow.Selection.InsertParagraphAfter
obDc.ActiveWindow.Selection.InsertAfter "The Big Text"
obDc.ActiveWindow.Selection.InsertParagraphAfter
obDc.ActiveWindow.Selection.Font.Bold = True
obDc.ActiveWindow.Selection.EndOf
obWrd.Quit False
Set obWrd = Nothing
End Sub
Public objword1 As Word.Application
Private Sub Form_Load()
Dim objDoc1 As Word.Document
Set objWord = New Word.Application
objword1.Visible = True
Set objDoc = objWord.Documents.Add
objDoc1.Activate
objDoc1.ActiveWindow.Selection.InsertAfter ("The Text")
On Error Resume Next
objDoc1.CheckSpelling
If Err Then
MsgBox Err.Description & Err.Number
End If
End Sub
Private Sub Form_Load()
Dim objWord As Object
Set objWord = CreateObject("Word.Basic")
objWord.filenew
objWord.startofdocument
objWord.FontSize 24
objWord.Insert "Big Letter Text"
objWord.FontSize 12
objWord.insertpara
objWord.Insert "Text with Smaller Font"
objWord.filesaveas "D:\test.doc"
'objWord.Close
Set objWord = Nothing
End Sub