Start Word within Excel 2007

R

Ralf Escher

Hello!

The following code worked fine with Excel 2000:

Dim myWord As Word.Application
Dim Dokument As Word.Document
Set meinWord = GetObject(, "Word.Application")

If myWord Is Nothing Then
Set myWord = CreateObject("Word.Application")
End If

Excel 2003 & 2007 doesn't accept this code.
Dim myWord As Microsoft.Office.Interop.Word.Application
also doesn't works.

How can I register/assign Microsoft.Office.Interop?
Can't find it at my Excel 2007 Add-Ins.

Thanks for any hints
Ralf
 
N

Norman Jones

Hi Ralf,

Try:


'==========>>
Public Sub Tester()
Dim myWord As Word.Application
Dim Dokument As Word.Document

On Error Resume Next
Set myWord = GetObject(, "Word.Application")
On Error GoTo 0

If myWord Is Nothing Then
Set myWord = CreateObject("Word.Application")
End If

myWord.Visible = True

'your code

myWord.Quit
Set myWord = Nothing
End Sub
'==========>>
 
R

Ralf Escher

Hi Norman,



thanks for the hint.

The problem is: my Excel VBA doesn't know the object "Word" or
"Microsoft.Office.Interop"



I have no idea how to register any Word or Office Automation Servers to add
this kind of objects.

Programming with my previous Excel 2000 worked find with "Word.Application".

But Excel 2007 doesn't know this object.



Normally I access the Microsoft Word x.0 Object Library in my application
but I can't find it in Excel 2007.



Thanks

Ralf
 
N

Norman Jones

Hi Ralf,

===========
[...]
Normally I access the Microsoft Word x.0 Object Library in my application
but I can't find it in Excel 2007.
===========

I tested the code under Excel 2007 and
I added a reference to the:

Microsoft Word 12.0 Object Library
 
R

Ralf Escher

Problem solved due to the hint of Norman in another message (accessing
Outlook).

I only had to add the Word Object Library in Excel 2007

VBA -> Extras -> References

Thanks
Ralf
 
N

Norman Jones

Hi Ralf,

============
[...]
VBA -> Extras -> References
============


In my English version, it would be:

VBA -> Tools -> References


I am glad that you have resolved your problem!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top