Identifying the calling Word document

S

sprungli

My add-in calls a COM object (a COM Callable Wrapper, or CCW). Consider the
scenario when there are several Word docs open. From the CCW, how can I know
exactly what Word document is calling.

TIA
 
P

Peter Hewett

Hi sprungli

Your question is very ambiguous. I assume it's from within the COM object that you need to
determine what document is being referenced. Well it depends on whether the code that
calls your COM object is referring to the ActiveDocument or not. Presumably your COM
object has a reference to the running Word application object? In this case the COM
object could refer to the Word applications ActiveDocument property. It's not good
practice to do this because your making implicit assumptions about how the caller is
interacting with Word. In other words the caller may not be referring to the
ActiveDocument but another document. The best practice would be to pass your COM object a
Document reference that it uses, this avoids any ambiguity about what document it's really
dealing with.

HTH + Cheers - Peter
 
S

sprungli

Thanks Peter,

that's exactly what I want to do. The problem is how to access the Word app
from the CCW. I only have acces to the .NET code, not to the resulting CCW.
How can I refer to the Word app from .NET? Note that the caller is a regular
template addin, not a COM addin.

TIA
 

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