Wednesday, May 1, 2013

How to Connect VB6 to MS Word


'Add References file in VB6 > Microsoft Word 12.0 Object Library

Option Explicit

Private Sub Command1_Click()

Dim WordObj As Word.Application
Set WordObj = CreateObject("Word.Application")
Dim objWord As Word.Document
Set objWord = WordObj.Documents.Open(FileName:=App.Path & "\Report.docx")
WordObj.Visible = True
With objWord.Bookmarks
.Item("NAME").Range.Text = txtName.Text
.Item("AGE").Range.Text = txtAge.Text
End With
Set objWord = Nothing

End Sub

Visual Basic 6 screen shot













'
'

Bork mark on MS Word