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 do I open a wordpro document in vb?

Status
Not open for further replies.

suna

Programmer
Apr 16, 2001
5
MY
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


Thanx!

Suna
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top