PC Review


Reply
Thread Tools Rate Thread

How to access Application Ojbect of the Current Excel Window in C#

 
 
=?Utf-8?B?RG9u?=
Guest
Posts: n/a
 
      7th Oct 2007
Hi,

I have a very basic need, and I cannot seem to find it address ANYWHERE on
the net.

I need to get access to the application object that is CURRENTLY OPEN.

I find tons of code that says use:

Excel.Application obj = new Excel.Application();

This starts a new Excel application, and that does me no good. I want to
access the active excel spreadsheet. I have found no examples or articles or
questions regarding this and it's been quite frustrating.

Just to be clear, I want something like:

Excel.Application obj = Excel.ActiveAppliation();

or

Excel.Application obj = Excel.CurrentApplication();

-Don
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      7th Oct 2007
Don: there ared two methods I use when I get frustrated the way you are which
is quite often with excel.

1) I add a statement into excel
Set Myappl = Application
The I set through the instruction and add Myappl to the watch window by
right clicking on Myappl in the code. This gives me a view of all the
methods that are accessable and the parameters assigned to them. Most likely
you will find under applications items and one of the items is the open
application
Application can be added to the watch window manually by just typing
Application as a new watch. OPen Watch window from Debug Menu then roght
click on watch window to add items.

Below doesn't work for application. You need to specify a type of
application that you would find in the watch window.
2) Use this code below which gets all the items
for each MyAppl in Application
'you may need to filter out some applications
'
if instr(MyAppl.name,"App name) > 0 then
'add your code here
end if
next MyAppl

In this case

"Don" wrote:

> Hi,
>
> I have a very basic need, and I cannot seem to find it address ANYWHERE on
> the net.
>
> I need to get access to the application object that is CURRENTLY OPEN.
>
> I find tons of code that says use:
>
> Excel.Application obj = new Excel.Application();
>
> This starts a new Excel application, and that does me no good. I want to
> access the active excel spreadsheet. I have found no examples or articles or
> questions regarding this and it's been quite frustrating.
>
> Just to be clear, I want something like:
>
> Excel.Application obj = Excel.ActiveAppliation();
>
> or
>
> Excel.Application obj = Excel.CurrentApplication();
>
> -Don

 
Reply With Quote
 
Tim Williams
Guest
Posts: n/a
 
      7th Oct 2007
Have you tied this?

http://msmvps.com/blogs/pauldomag/ar.../15/86417.aspx

Tim

"Don" <(E-Mail Removed)> wrote in message
news:764DD568-F0FF-473D-B30B-(E-Mail Removed)...
> Hi,
>
> I have a very basic need, and I cannot seem to find it address ANYWHERE on
> the net.
>
> I need to get access to the application object that is CURRENTLY OPEN.
>
> I find tons of code that says use:
>
> Excel.Application obj = new Excel.Application();
>
> This starts a new Excel application, and that does me no good. I want to
> access the active excel spreadsheet. I have found no examples or articles
> or
> questions regarding this and it's been quite frustrating.
>
> Just to be clear, I want something like:
>
> Excel.Application obj = Excel.ActiveAppliation();
>
> or
>
> Excel.Application obj = Excel.CurrentApplication();
>
> -Don



 
Reply With Quote
 
=?Utf-8?B?RG9u?=
Guest
Posts: n/a
 
      7th Oct 2007
Hi Joel,

Thanks for the response. It's unfortunate that the title of my post got cut
short. It ended in "in C#".

What you suggested works perfectly in VBA editor using VB.NET. The problem
is, when using VS2005 and C#.NET, there is no "Application" that you speak
of. If I could get the functionality that exists in VB into C#, I'd be happy,
but so far I see no way to do it.

"Application" as you mentioned it is exactly what I'm trying to locate in C#.

"Joel" wrote:

> Don: there ared two methods I use when I get frustrated the way you are which
> is quite often with excel.
>
> 1) I add a statement into excel
> Set Myappl = Application
> The I set through the instruction and add Myappl to the watch window by
> right clicking on Myappl in the code. This gives me a view of all the
> methods that are accessable and the parameters assigned to them. Most likely
> you will find under applications items and one of the items is the open
> application
> Application can be added to the watch window manually by just typing
> Application as a new watch. OPen Watch window from Debug Menu then roght
> click on watch window to add items.
>
> Below doesn't work for application. You need to specify a type of
> application that you would find in the watch window.
> 2) Use this code below which gets all the items
> for each MyAppl in Application
> 'you may need to filter out some applications
> '
> if instr(MyAppl.name,"App name) > 0 then
> 'add your code here
> end if
> next MyAppl
>
> In this case
>


 
Reply With Quote
 
=?Utf-8?B?RG9u?=
Guest
Posts: n/a
 
      8th Oct 2007
That's exactly that I needed!

Thanks Tim

"Tim Williams" wrote:

> Have you tied this?
>
> http://msmvps.com/blogs/pauldomag/ar.../15/86417.aspx
>
> Tim
>
> "Don" <(E-Mail Removed)> wrote in message
> news:764DD568-F0FF-473D-B30B-(E-Mail Removed)...
> > Hi,
> >
> > I have a very basic need, and I cannot seem to find it address ANYWHERE on
> > the net.
> >
> > I need to get access to the application object that is CURRENTLY OPEN.
> >
> > I find tons of code that says use:
> >
> > Excel.Application obj = new Excel.Application();
> >
> > This starts a new Excel application, and that does me no good. I want to
> > access the active excel spreadsheet. I have found no examples or articles
> > or
> > questions regarding this and it's been quite frustrating.
> >
> > Just to be clear, I want something like:
> >
> > Excel.Application obj = Excel.ActiveAppliation();
> >
> > or
> >
> > Excel.Application obj = Excel.CurrentApplication();
> >
> > -Don

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Application Window Tiling when Help is clicked on and application is not set to maximize Ronald R. Dodge, Jr. Microsoft Excel Discussion 0 12th Aug 2009 07:21 PM
How can I get Memory used by Current Excel Application? MikeZz Microsoft Excel Programming 1 24th Sep 2008 09:05 PM
1004 Application Defined or Ojbect Defined error Nasir.Munir@dal.ca Microsoft Excel Programming 2 12th Feb 2007 02:38 PM
Switch database in current Access 2003 application window =?Utf-8?B?SmVmZiBHcnVuZHk=?= Microsoft Access VBA Modules 1 18th Jan 2005 08:38 PM
How can i access the current sessions in the application? Michael Ulmann Microsoft ASP .NET 1 22nd Jul 2004 11:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:07 PM.