Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Retrieving Current Excel Instance from Automation Add-IN

I have created an Automation Addin with the following code.

[ClassInterface(ClassInterfaceType.AutoDual)]
public class TestFunctions
{
private ApplicationClass excelApplication;

public TestFunctions()
{
// this.excelApplication = SOMETHING
}

[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type type)
{
Registry.ClassesRoot.CreateSubKey(GetSubKeyName(ty pe));
}

[ComUnregisterFunctionAttribute]
public static void UnregisterFunction(Type type)
{
Registry.ClassesRoot.DeleteSubKey(GetSubKeyName(ty pe),false);
}

private static string GetSubKeyName(Type type)
{
string s = @"CLSID\{" + type.GUID.ToString().ToUpper() + @"}\Programmable";
return s;
}

Using the code above I want to grab the instance of Excel THAT THE ADD_IN is
RUNNING in. I tried this.excelAppication = new ApplicationClass(), but that
just creates a new excel instance.

Any suggestions would be very helpful.

Thank you,

mduncan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Retrieving Current Excel Instance from Automation Add-IN

If its a vs office addin project:
the boiler plate code should include an
object called applicationObject, you should be able to reference that (its
private within the connect class so you'll have to make it public/global or
put an accessor routine in)
applicationObject is set on connection

if its a vs office project:
The boiler plate code should include an
Excel.Application called ThisApplication, you should be able to reference
that directly?
(I'm using VS.net 2003)

cheers
simon

"mduncan" wrote:

I have created an Automation Addin with the following code.

[ClassInterface(ClassInterfaceType.AutoDual)]
public class TestFunctions
{
private ApplicationClass excelApplication;

public TestFunctions()
{
// this.excelApplication = SOMETHING
}

[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type type)
{
Registry.ClassesRoot.CreateSubKey(GetSubKeyName(ty pe));
}

[ComUnregisterFunctionAttribute]
public static void UnregisterFunction(Type type)
{
Registry.ClassesRoot.DeleteSubKey(GetSubKeyName(ty pe),false);
}

private static string GetSubKeyName(Type type)
{
string s = @"CLSID\{" + type.GUID.ToString().ToUpper() + @"}\Programmable";
return s;
}

Using the code above I want to grab the instance of Excel THAT THE ADD_IN is
RUNNING in. I tried this.excelAppication = new ApplicationClass(), but that
just creates a new excel instance.

Any suggestions would be very helpful.

Thank you,

mduncan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Retrieving Current Excel Instance from Automation Add-IN

Thank you. The on connection solution works perfectly!

"Simon Murphy" wrote:

If its a vs office addin project:
the boiler plate code should include an
object called applicationObject, you should be able to reference that (its
private within the connect class so you'll have to make it public/global or
put an accessor routine in)
applicationObject is set on connection

if its a vs office project:
The boiler plate code should include an
Excel.Application called ThisApplication, you should be able to reference
that directly?
(I'm using VS.net 2003)

cheers
simon

"mduncan" wrote:

I have created an Automation Addin with the following code.

[ClassInterface(ClassInterfaceType.AutoDual)]
public class TestFunctions
{
private ApplicationClass excelApplication;

public TestFunctions()
{
// this.excelApplication = SOMETHING
}

[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type type)
{
Registry.ClassesRoot.CreateSubKey(GetSubKeyName(ty pe));
}

[ComUnregisterFunctionAttribute]
public static void UnregisterFunction(Type type)
{
Registry.ClassesRoot.DeleteSubKey(GetSubKeyName(ty pe),false);
}

private static string GetSubKeyName(Type type)
{
string s = @"CLSID\{" + type.GUID.ToString().ToUpper() + @"}\Programmable";
return s;
}

Using the code above I want to grab the instance of Excel THAT THE ADD_IN is
RUNNING in. I tried this.excelAppication = new ApplicationClass(), but that
just creates a new excel instance.

Any suggestions would be very helpful.

Thank you,

mduncan

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
retrieving current data dave303159 Excel Worksheet Functions 1 March 18th 10 07:40 PM
Retrieving 'current' data tommo Excel Worksheet Functions 2 February 28th 08 02:02 PM
Is it possible to prevent opening of workbooks in the current instance of Excel? [email protected] Excel Programming 0 January 26th 05 09:41 PM
Retrieving text being typed and cursor position using VBA or automation, how? Kallepalle Excel Programming 2 May 23rd 04 12:40 PM
Second instance of Excel Dom[_2_] Excel Programming 1 August 25th 03 05:37 PM


All times are GMT +1. The time now is 01:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"