Hi,
I have used VSTO 2005 to create an Outlook 2003 add-in which depends on a
custom template (*.oft).
In my setup project, I have kept the default installation folder for the
add-in to [Program Files]\[Company Name]\[Product Name] and therefore the
template installs to a subfolder called Template.
The problem I have is when I want to load the template from my code, as
shown in the snippet below:
using Ol = Microsoft.Office.Interop.Outlook;
using Mso = Microsoft.Office.Core;
private void OnButtonClick(Mso.CommandBarButton button, ref bool
cancelDefault)
{
// Open the custom form and display it to the user.
Ol.Application _app = (Ol.Application)button.Application;
string templatePath =
String.Format(Constants.DefaultTemplatePath, Application.StartupPath,
Constants.DefaultTemplateName);
Ol.MailItem item =
(Ol.MailItem)_app.CreateItemFromTemplate(templatePath, Type.Missing);
item.Display(false);
}
The issue is that Application.StartupPath returns the path to where MS
Outlook 2003 is installed (C:\Program Files\Microsoft\Office\Office11) not
the path to where my add-in is installed.
Is there any way to programmatically reference the location where the add-in
is running from?
Regards,
Rick Clarke - 26 Jan 2007 19:39 GMT
Try this
string codeBaseDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Substring(8));
Rick Clarke - 26 Jan 2007 19:54 GMT
Try using System.Reflection.Assembl
string codeBaseDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase.Substring(8));
Jazza - 30 Jan 2007 12:50 GMT
Thanks, I used another method
> Try using System.Reflection.Assembly
>
> string codeBaseDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase.Substring(8));
> ---
> Posted via DotNetSlackers.com