Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to open wordpro in vb

Status
Not open for further replies.

suna

Programmer
Apr 16, 2001
5
MY
Hi..
i'm trying to open a wordpro document in vb and generate a letter,by which part of the data are from the database.

for now, i'm using this method but i don't think it is a good practice....

Dim oword As Object
Dim WordProDoc As Object

Set oword = CreateObject("Word.Application")
With oword

.Documents.Add 'Open blank MSWord document
.Selection.Font.Name = "Arial"
.
.
.

.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.Font.Bold = True
.Selection.Font.Underline = True
.Selection.TypeText ("LETTER OF APPOINTMENT")
.Selection.Font.Bold = False
.Selection.Font.Underline = False
.
.

'to insert data from db
.Selection.TypeText ("( " & rsInduk!P_name & " )")
.Selection.TypeParagraph


.ActiveDocument.SaveAs ("E:\SPAN\MySpan2\pelantikan tetap.lwp")
.Quit

End With


Set WordProDoc = GetObject("E:\SPAN\MySpan2\pelantikan tetap.lwp", "WordPro.Document")
WordProDoc.Application.ActiveDocWindow.Show

'clear the recordset on the way out
Set rsInduk = Nothing
MsgBox "process completed, double click on the Wordpro icon to view the letter", vbInformation
OLE1.Enabled = True






 
You may be WAY ahead of the curve if you use Word MailMerge which is developed especially for this type activity. You then don't even need to use VBA but merely build the mail merge document, set a data source, and go with it.
-------------------------------------
scking@arinc.com
Try to resolve problems independently
Then seek help among peers or experts
But TEST recommended solutions
-------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top