Hello Nick,
From your post, my understanding on this issue is: you want to know how to
resolve the error LNK1179 (invalid or corrupt file: duplicate COMDAT
'_IID_AddIn') and how to access the Application object in the shared
add-in. If I'm off base, please feel free to let me know.
For the first question, error LINK1179 indicates that there are some
duplicate Class of Interface defined in the libraries you #imported. To
resolve the error, you need to rename the namespace of imported libraries.
For instance:
In the project¡¯s stdafx.h, add the following code: (NOTE: the attribute
¡®named_guids¡¯ is removed)
#import "C:\\Program Files\\Microsoft Office\\Office\\mso9.dll"
rename_namespace("Office2000")
using namespace Office2000;
#import "C:\\Program Files\\Common Files\\Microsoft
Shared\\VBA\\VBA6\\VBE6EXT.olb"
rename_namespace("VBE6")
using namespace VBE6;
In the project¡¯s Addin.h file, towards the top, add:
#import "C:\\Program Files\\Microsoft Office\\Office\\MSWORD9.olb"
rename("ExitWindows","MyExitWindows"),named_guids,
rename_namespace("MSWord")
using namespace MSWord;
You may also refer to the code project article:
http://www.codeproject.com/com/adwordaddin.asp, to learn how to use #import
to do automation from VC++.
For the second question about how to access the Application object, you
need to implement the interface: _IDTExtensibility2 in your add-in class.
In the method: OnConnection of _IDTExtensibility2, it has a parameter
IDispatch * Application:
STDMETHOD(OnConnection)(IDispatch * Application, ext_ConnectMode
ConnectMode, IDispatch * AddInInst, SAFEARRAY * * custom) {¡}
This ¡®Application¡¯ points to the Application object we are in need of.
CComQIPtr <Word::_Application> spApp(Application);
Please let me know if you have any other concerns, or need anything else.
Sincerely,
Jialiang Ge (
[email protected], remove ¡®online.¡¯)
Microsoft Online Community Support
==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document:
http://blogs.msdn.com/msdnts/pages/postingAlias.aspx
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box ¡°Tools/Options/Read: Get 300 headers at a time¡±
to see your reply promptly.
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://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided ¡°AS IS¡± with no warranties, and confers no
rights.