Word document inserted into Excel spreadsheet

  • Thread starter Peter Karlström
  • Start date
P

Peter Karlström

Hi

When a user inserts a Word document into Excel using menu Insert - Object
(From file) there is no Word window opened to the user.
This is the standard way.

However, when we are activating my COM Addin in Word, a Word window is
opened, and this is not desired.

I have tried looking at the property ActiveDocument.Container in the
DocumentOpen event of the COM Addin. but this doesn't seem to be the correct
way. It says this is not OLE.....

How can I check where the document is hosted, in order to disable the window
from showing up in this perticular situation?

Thanks in advance
 
C

Colbert Zhou [MSFT]

Hello Peter,

The Word.Application.UserControl will return false if it is embedded in the
Excel. But the exact meaning of this property is,(
http://msdn.microsoft.com/en-us/library/bb179589.aspx )

"The UserControl property returns False if the application was created or
opened programmatically from another Microsoft Office application with the
Open method or the CreateObject or GetObject method."

So I am not very sure if the UserControl is enough to handle the logic in
your scenario. If not, we may need to go the WMI way to find the Word
application's parent process name. Please see a previous discussion in the
VSTO forum,
http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/e0838c01-6ba2-4fc2
-ace7-f1505a86f58f/

Does this helps? If you need any future assistance on this, please feel
free let me know. Have a good day!


Best regards,
Colbert Zhou (colbertz @online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter Karlström

Hi Colbert

I found a way to keep the Word window closed if the document was inserted as
an object in Excel.

In my COM Addin event for DocumentOpen, I put the following lines in the top:

On Error Resume Next
If wrdApp.ActiveDocument.Name = "" Then
Exit Sub
End If

wrdApp is the Word application object of in the Addin.

This seems to work fine testing the Insert Object from Excel and opening
document the ordinary way.

Best Regards
--
Peter Karlström
Midrange AB
Sweden
 
C

Colbert Zhou [MSFT]

Thanks for also sharing your resolution. Then if you have any questions on
this in future, please feel free to update the thread.


Best regards,
Colbert Zhou (colbertz @online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
 

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