code help with vb 6.0

Konnan
08-08-2001, 09:45 PM
in vb 6.0 can set up a command button which will open my word document and if so how?

Conan Visinko

dcl3500
08-08-2001, 10:08 PM
Dim objWord As New Word.Application
Set objWord = New Word.Application
objWord.Documents.Open ("Your path and filename here")
objWord.Visible = True
Set objWord = Nothing

This should work for you. Just put it in your command button's click_event.

Don

Time is the best teacher; unfortunately it kills all its students.

Konnan
08-08-2001, 10:22 PM
its giving me a compile error user-definded type not defined

this is what is the code i have

Private Sub Command1_Click()
Dim objWord
Dim objWord As New Word.Application ' vb highlights this line when i get the error
Set objWord = New Word.Application
objWord.Documents.Open ("c:\user name.doc")
objWord.Visible = True
Set objWord = Nothing

Conan Visinko

dcl3500
08-08-2001, 10:44 PM
I think you need to set a reference to the Microsoft Word 9.0 Object Library. You do this in Projects|References

Sorry I forgot to mention that.

Don

Time is the best teacher; unfortunately it kills all its students.

Konnan
08-08-2001, 10:57 PM
ok gonna try that not and work that out not sure how to set a reference to the Microsoft Word 9.0 Object Library
but im gonna sit down and work it out

thanks

Conan Visinko

dcl3500
08-08-2001, 11:10 PM
You go to the Project menu and click on Preferences. In the resulting list you will find Microsoft Word 9.0 Object Library. Select it and click Ok and you will be on your way images/icons/smile.gif

I guess I should have asked. Do you have Word 2000 on your system. My method works with Word 2000. I don't know about any of the other versions though.

I'll be back online tommorrow night if you still need an assist. Or someone else will pick up the ball and give you a hand.

Don


Time is the best teacher; unfortunately it kills all its students.

Konnan
08-08-2001, 11:12 PM
yea i ahve word 2000

Conan Visinko

Konnan
08-08-2001, 11:17 PM
Cheers ur a champ i got it working

Conan Visinko

dcl3500
08-08-2001, 11:22 PM
Good to hear. Have a good one

Don

Time is the best teacher; unfortunately it kills all its students.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum