|
-
Sep 4th, 2001, 08:42 PM
#1
Thread Starter
Lively Member
how to create an instance of ms word using vb?
people,
how do you open a ms word document in vb? i kept receiving this error:
"Activex component can't create object"
thanks!
-
Sep 4th, 2001, 08:43 PM
#2
-= B u g S l a y e r =-
VB Code:
Option Explicit
Private objWord As Word.Application
Private wd As Word.Document
Private Sub Command1_Click()
Dim myRange As Range
Dim sSearchfor As String
If objWord Is Nothing Then
Set objWord = CreateObject("Word.Application")
Else
Set objWord = GetObject(, "Word.Application")
End If
DoEvents
Set wd = objWord.Documents.Open("c:\Test.doc")
'here u can do stuff with the document
'using the wd object
'when finished manipulating the document, u can show _
it To the user
objWord.Visible = True
End Sub
-
Sep 4th, 2001, 08:49 PM
#3
Thread Starter
Lively Member
same error
Option Explicit
Private objWord As Word.Application
Private wd As Word.Document
Private Sub Command1_Click()
Dim myRange As Range
Dim sSearchfor As String
If objWord Is Nothing Then
Set objWord = CreateObject("Word.Application")
Else
Set objWord = GetObject(, "Word.Application")
End If
DoEvents
Set wd = objWord.Documents.Open("c:\Test.doc")
'here u can do stuff with the document
'using the wd object
'when finished manipulating the document, u can show _
it To the user
objWord.Visible = True
End Sub
still got the same error message.
does it have something to do with dll's or license etc.?
-
Sep 4th, 2001, 08:52 PM
#4
-= B u g S l a y e r =-
Have u referenced the Microsoft Word Object?
-
Sep 4th, 2001, 08:59 PM
#5
Thread Starter
Lively Member
yes.
microsoft word 9.0 object library.
-
Sep 4th, 2001, 09:02 PM
#6
-= B u g S l a y e r =-
At what line in the code does the error occur?
-
Sep 4th, 2001, 09:07 PM
#7
Thread Starter
Lively Member
the CreateObject line.
before, i used
dim appword as word.application
Set appword = NEW word.application
but i received the same error. my guess is that because of the its of the NEW command. it worked when i first opened the MS word application manually then referenced the appword object to the word.application (Set appword = word.application)
-
Sep 4th, 2001, 09:13 PM
#8
Frenzied Member
Err...if all you want to do is open a word instance...this works for me (after word references are added):
VB Code:
Dim WordApp As New Word.Application
WordApp.Visible = True
And if you want to add a blank doc, do
Although i might have missed something since Peet has way more code than that.
You just proved that sig advertisements work.
-
Sep 4th, 2001, 09:23 PM
#9
Thread Starter
Lively Member
still the same error
maybe this could help.
The computer on which you are running the code has a run-time license rather than a design-time license for this control.
With a run-time license, you can load the control but you cannot create or insert it. The design-time license for this control ships with the Microsoft Office 2000 Developer Edition or Microsoft Visual Studio. It does not ship with other versions of Microsoft Office 2000.
-
Sep 5th, 2001, 03:18 AM
#10
Thread Starter
Lively Member
-
Sep 5th, 2001, 04:25 PM
#11
Frenzied Member
Lol well if you know that you dont have the license..then working around it is probably illegal....but like thats ever stopped anyone
You just proved that sig advertisements work.
-
Sep 19th, 2001, 09:08 AM
#12
Member
had this problem
I actually had this problem for awhile, working with windows 2000 and office 2000. The solution to your problem is installing an older version of the office update. If you install the lates office update (2) then this will solve the problem, it is also recommended that you install any updates to windows 2000. Your code is right, if you compile and run on another machine it will work. Good Luck
U S A
Visual Studio .NET
Windows XP
-
Sep 25th, 2001, 02:53 AM
#13
Thread Starter
Lively Member
thank you very much for your reply!!!
what again should i do?
should i install the older office update or the lates office update?
thanks again !!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|