Link to home
Start Free TrialLog in
Avatar of jetyun
jetyun

asked on

Open Word document from VB?

I m not sure which method is recommended to open a word document from VB? Pls advise.
Avatar of venkatravi_78
venkatravi_78

Do like this.
'first goto-project-references-select microsoft word 9.0 object library-ok

dim oword as object
dim wrddoc as object
dim blnrunning as boolean

On Error Resume Next
Set oword = GetObject(, "word.application")

If Err.Number <> 0 Then
Set oword = CreateObject("word.application")
oword.Visible = True
blnrunning = False
Else
blnrunning = True
End If

AppActivate (oword)

Set WRDDOC = oword.Documents.Add
ASKER CERTIFIED SOLUTION
Avatar of xmetrix
xmetrix

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Add reference to Microsoft Word Object Library 8.0
PAste the code in a button click event.


Dim Obj As New Word.Application
Obj.Documents.Open "Whole path of your document"
Obj.Visible = True
Can it be done without a refrence to Word?