Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / VS Tools for Office / January 2007

Tip: Looking for answers? Try searching our database.

Application.StartupPath Question in VSTO 2005

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jazza - 26 Jan 2007 12:43 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.