Shared Add-in Startup directory?

P

Peter

Hello

Thanks for reviewing my question. I have written a shared Add-in program. At run-time, I would like to know how can the shared Add-in find out which directory it is in? My goal is to have a configuration file in the same location as my Add-in

Many Thanks to the Expert
Peter
 
T

Tom Winter

What Office application is the add-in for? What language is it written in?
My guess is a Word .DOT template in the STARTUP folder. Is that correct?
--
Tom Winter
(e-mail address removed)
www.AmosFiveSix.com

Peter said:
Hello,

Thanks for reviewing my question. I have written a shared Add-in program.
At run-time, I would like to know how can the shared Add-in find out which
directory it is in? My goal is to have a configuration file in the same
location as my Add-in.
 
C

Chango V.

Using Win32, one way is GetModuleHandle() + GetModuleFileName().

//

Peter said:
Hello,

Thanks for reviewing my question. I have written a shared Add-in program.
At run-time, I would like to know how can the shared Add-in find out which
directory it is in? My goal is to have a configuration file in the same
location as my Add-in.
 
T

Tom Winter

I saw you post in the VSTO group. If you are doing .NET, that's probably the
best place to ask, though it really isn't an office specific question. Other
..NET groups could probably answer the question.

I know if VB6, you can do VB.App.Path. I don't know if there is something
similar in VB.NET. I have also used Chango's suggestion in VB6.
 
P

Peter

I figured it out. You can do either two ways shown below:

Assembly mainAssembly = Assembly.GetExecutingAssembly();
Console.WriteLine("Location is {0}", mainAssembly.Location );

Module mainMod = mainAssembly.GetModules()[0];
Console.WriteLine("Location is {0}", mainMod.FullyQualifiedName );
 

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