ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Start Word within Excel 2007 (https://www.excelbanter.com/excel-programming/411277-start-word-within-excel-2007-a.html)

Ralf Escher

Start Word within Excel 2007
 
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



Norman Jones[_2_]

Start Word within Excel 2007
 
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
'==========



---
Regards.
Norman


"Ralf Escher" wrote in message
...
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



Ralf Escher

Start Word within Excel 2007
 
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



"Norman Jones" schrieb im Newsbeitrag
...
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
'==========



---
Regards.
Norman


"Ralf Escher" wrote in message
...
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





Norman Jones[_2_]

Start Word within Excel 2007
 
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



---
Regards.
Norman


Ralf Escher

Start Word within Excel 2007 [SOLVED]
 
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



Norman Jones[_2_]

Start Word within Excel 2007 [SOLVED]
 
Hi Ralf,

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


In my English version, it would be:

VBA - Tools - References


I am glad that you have resolved your problem!


---
Regards.
Norman

"Ralf Escher" wrote in message
...
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




All times are GMT +1. The time now is 06:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com