Getting added to the new documents types

D

David Thielen

J

Jie Wang [MSFT]

I didn't see my reply appear on the NG. So I'm re-sending it:

Hi David,

You can just copy your pre-made template files into the Office template
folders.

In order to popup some customized UI when users create new document based
on your templates, you can add macros to the templates. Since the template
folders are trusted by Office applications by default, these macros will be
run without warnings.

Here is the reference for how to manage templates in 2007 Office programs:
http://support.microsoft.com/kb/924460

You can deploy your templates to the folders described in the article above.

If you have any further questions regarding this issue, please let me know.

Regards,

Jie Wang ([email protected], 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: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days 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. 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/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

fantastic - thanks - dave


I didn't see my reply appear on the NG. So I'm re-sending it:

Hi David,

You can just copy your pre-made template files into the Office template
folders.

In order to popup some customized UI when users create new document based
on your templates, you can add macros to the templates. Since the template
folders are trusted by Office applications by default, these macros will be
run without warnings.

Here is the reference for how to manage templates in 2007 Office programs:
http://support.microsoft.com/kb/924460

You can deploy your templates to the folders described in the article above.

If you have any further questions regarding this issue, please let me know.

Regards,

Jie Wang ([email protected], 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: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days 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. 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/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
D

David Thielen

C

Cindy M.

Hi David,
I'm finally diving in to this and am already stuck. How do I write a
macro that calls a method in my AddIn?

Have you seen Andrew Whitechapel's blog posts on the topic

http://blogs.msdn.com/andreww/archive/2008/08/13/comaddins-race-
condition.aspx

http://blogs.msdn.com/andreww/archive/2008/08/11/why-your-comaddin-
object-should-derive-from-standardolemarshalobject.aspx

http://blogs.msdn.com/andreww/archive/2008/10/13/exposing-events-from
-managed-add-in-objects.aspx

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
J

Jie Wang [MSFT]

Hi David,

The URLs that Cindy posted are really great readings for this topic
(exposing objects in COM Add-ins for VBA consumers).

Here let me show you a simple example - suppose you're using the C# & C++
add-in shim loader according to your previous posts.

First, you need to create a class that will be called by the VBA macros:

/// <summary>
/// Interface for AddInClass
/// </summary>
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IAddInClass
{
string GetAsmInfo();
}

/// <summary>
/// The implementation of IAddInClass interface.
/// </summary>
[ComVisible(true), ClassInterface(ClassInterfaceType.None)]
public class AddInClass : StandardOleMarshalObject, IAddInClass
{
public string GetAsmInfo()
{
return Assembly.GetExecutingAssembly().ToString();
}
}

Now we have the AddInClass, next is to set an ref to the instance of the
class to the COMAddIn.Object property.

In your Add-in's OnConnection method (on IDTExtensibility2 interface):

public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom)
{
......

// cast the addInInst to the COMAddIn interface, set the ref to
AddInClass instance to the Object property.
((Microsoft.Office.Core.COMAddIn)addInInst).Object = new AddInClass();
}

After rebuilding & installing your add-in, you can now write the VBA code
in your Office application:

Sub Test()
Dim addIn As COMAddIn
Dim automationObject As Object

' ExposeToVBA.Connect is the ProgId defined in the Add-in.
Set addIn = Application.COMAddIns("ExposeToVBA.Connect")
' Access the Object property, get the AddInClass instance.
Set automationObject = addIn.Object

' Call the GetAsmInfo method.
MsgBox automationObject.GetAsmInfo
End Sub

That is the simplest sample for exposing an object to the VBA macro from
within the managed COM Add-in.

If you're using VSTO, the only difference is not to use the OnConnection,
but to override the RequestComAddInAutomationService method.

Please let me know if this works for you. Any questions please also let me
know.

Thanks,

Jie Wang

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: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days 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. 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/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

Cindy & Jie - THANK YOU. Between Jie's example and Cindy's pointers to
Andrew's blog I'm running.

thanks - dave


Hi David,

The URLs that Cindy posted are really great readings for this topic
(exposing objects in COM Add-ins for VBA consumers).

Here let me show you a simple example - suppose you're using the C# & C++
add-in shim loader according to your previous posts.

First, you need to create a class that will be called by the VBA macros:

/// <summary>
/// Interface for AddInClass
/// </summary>
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IAddInClass
{
string GetAsmInfo();
}

/// <summary>
/// The implementation of IAddInClass interface.
/// </summary>
[ComVisible(true), ClassInterface(ClassInterfaceType.None)]
public class AddInClass : StandardOleMarshalObject, IAddInClass
{
public string GetAsmInfo()
{
return Assembly.GetExecutingAssembly().ToString();
}
}

Now we have the AddInClass, next is to set an ref to the instance of the
class to the COMAddIn.Object property.

In your Add-in's OnConnection method (on IDTExtensibility2 interface):

public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom)
{
......

// cast the addInInst to the COMAddIn interface, set the ref to
AddInClass instance to the Object property.
((Microsoft.Office.Core.COMAddIn)addInInst).Object = new AddInClass();
}

After rebuilding & installing your add-in, you can now write the VBA code
in your Office application:

Sub Test()
Dim addIn As COMAddIn
Dim automationObject As Object

' ExposeToVBA.Connect is the ProgId defined in the Add-in.
Set addIn = Application.COMAddIns("ExposeToVBA.Connect")
' Access the Object property, get the AddInClass instance.
Set automationObject = addIn.Object

' Call the GetAsmInfo method.
MsgBox automationObject.GetAsmInfo
End Sub

That is the simplest sample for exposing an object to the VBA macro from
within the managed COM Add-in.

If you're using VSTO, the only difference is not to use the OnConnection,
but to override the RequestComAddInAutomationService method.

Please let me know if this works for you. Any questions please also let me
know.

Thanks,

Jie Wang

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: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days 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. 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/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 

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