people,
how do you open a ms word document in vb? i kept receiving this error:
"Activex component can't create object"
thanks!
Printable View
people,
how do you open a ms word document in vb? i kept receiving this error:
"Activex component can't create object"
thanks!
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
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.?
Have u referenced the Microsoft Word Object?
yes.
microsoft word 9.0 object library.
At what line in the code does the error occur?
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)
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
VB Code:
WordApp.Documents.Add
Although i might have missed something since Peet has way more code than that.;)
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.
anyone? please...
Lol well if you know that you dont have the license..then working around it is probably illegal....but like thats ever stopped anyone:D
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
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 !!!