PC Review


Reply
Thread Tools Rate Thread

How to deselect a selected chart programatically?

 
 
=?Utf-8?B?c3IxNTI=?=
Guest
Posts: n/a
 
      27th Jan 2006
I'm using the excel automation objects (Microsoft.Office.Interop.Excel) for
Office 2003. Using C#.NET I'm retrieving the list of worksheets in a
workbook. For each worksheet, if there is a chart on the worksheet there is a
further processing that is required. However, I need to de-select a selected
chart area (when the mouse is clicked on the chart area the chart and the
data columns get selected). I have used:
foreach(Excel.Chart chart in workbook.Charts)
{
try
{
chart.Deselect();
PageSetup(excelApp, chart);
}
catch(Exception err)
{
PlugInTrace.WriteException(err);
}
}

The above piece of code does not undo the selection of the chart area. Any
help is greatly appreciated.

Thanks.
 
Reply With Quote
 
 
 
 
Tushar Mehta
Guest
Posts: n/a
 
      27th Jan 2006
Do you have to select the chart in the first place? Select and activate are
often unnecessary.

To 'deselect' a chart, chart.Deselect should work. A limited test from the
VBE confirmed it worked. But, if it doesn't, select a cell.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article <7F322E0C-F3A5-4633-AE53-(E-Mail Removed)>, sr152
@discussions.microsoft.com says...
> I'm using the excel automation objects (Microsoft.Office.Interop.Excel) for
> Office 2003. Using C#.NET I'm retrieving the list of worksheets in a
> workbook. For each worksheet, if there is a chart on the worksheet there is a
> further processing that is required. However, I need to de-select a selected
> chart area (when the mouse is clicked on the chart area the chart and the
> data columns get selected). I have used:
> foreach(Excel.Chart chart in workbook.Charts)
> {
> try
> {
> chart.Deselect();
> PageSetup(excelApp, chart);
> }
> catch(Exception err)
> {
> PlugInTrace.WriteException(err);
> }
> }
>
> The above piece of code does not undo the selection of the chart area. Any
> help is greatly appreciated.
>
> Thanks.
>

 
Reply With Quote
 
=?Utf-8?B?c3IxNTI=?=
Guest
Posts: n/a
 
      27th Jan 2006
The chart area is already selected and because of that the data columns
associated with the chart are also selected. The code needs to deselect the
chart area, not just the lines on the chart but the entire chart area. The
above code is not doing that. Any suggestions?

Thanks.


"Tushar Mehta" wrote:

> Do you have to select the chart in the first place? Select and activate are
> often unnecessary.
>
> To 'deselect' a chart, chart.Deselect should work. A limited test from the
> VBE confirmed it worked. But, if it doesn't, select a cell.
>
> --
> Regards,
>
> Tushar Mehta
> www.tushar-mehta.com
> Excel, PowerPoint, and VBA add-ins, tutorials
> Custom MS Office productivity solutions
>
> In article <7F322E0C-F3A5-4633-AE53-(E-Mail Removed)>, sr152
> @discussions.microsoft.com says...
> > I'm using the excel automation objects (Microsoft.Office.Interop.Excel) for
> > Office 2003. Using C#.NET I'm retrieving the list of worksheets in a
> > workbook. For each worksheet, if there is a chart on the worksheet there is a
> > further processing that is required. However, I need to de-select a selected
> > chart area (when the mouse is clicked on the chart area the chart and the
> > data columns get selected). I have used:
> > foreach(Excel.Chart chart in workbook.Charts)
> > {
> > try
> > {
> > chart.Deselect();
> > PageSetup(excelApp, chart);
> > }
> > catch(Exception err)
> > {
> > PlugInTrace.WriteException(err);
> > }
> > }
> >
> > The above piece of code does not undo the selection of the chart area. Any
> > help is greatly appreciated.
> >
> > Thanks.
> >

>

 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      28th Jan 2006
You cannot select a chart and a worksheet range at the same time.

What needs to be selected? You could try this (translated into C#, of
course):

ActiveChart.Deselect
ActiveSheet.Range("A1").Select

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

"sr152" <(E-Mail Removed)> wrote in message
news:A134B358-EBA8-433C-A408-(E-Mail Removed)...
> The chart area is already selected and because of that the data columns
> associated with the chart are also selected. The code needs to deselect
> the
> chart area, not just the lines on the chart but the entire chart area. The
> above code is not doing that. Any suggestions?
>
> Thanks.
>
>
> "Tushar Mehta" wrote:
>
>> Do you have to select the chart in the first place? Select and activate
>> are
>> often unnecessary.
>>
>> To 'deselect' a chart, chart.Deselect should work. A limited test from
>> the
>> VBE confirmed it worked. But, if it doesn't, select a cell.
>>
>> --
>> Regards,
>>
>> Tushar Mehta
>> www.tushar-mehta.com
>> Excel, PowerPoint, and VBA add-ins, tutorials
>> Custom MS Office productivity solutions
>>
>> In article <7F322E0C-F3A5-4633-AE53-(E-Mail Removed)>, sr152
>> @discussions.microsoft.com says...
>> > I'm using the excel automation objects (Microsoft.Office.Interop.Excel)
>> > for
>> > Office 2003. Using C#.NET I'm retrieving the list of worksheets in a
>> > workbook. For each worksheet, if there is a chart on the worksheet
>> > there is a
>> > further processing that is required. However, I need to de-select a
>> > selected
>> > chart area (when the mouse is clicked on the chart area the chart and
>> > the
>> > data columns get selected). I have used:
>> > foreach(Excel.Chart chart in workbook.Charts)
>> > {
>> > try
>> > {
>> > chart.Deselect();
>> > PageSetup(excelApp, chart);
>> > }
>> > catch(Exception err)
>> > {
>> > PlugInTrace.WriteException(err);
>> > }
>> > }
>> >
>> > The above piece of code does not undo the selection of the chart area.
>> > Any
>> > help is greatly appreciated.
>> >
>> > Thanks.
>> >

>>



 
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
Help - my desktop is selected and I can't deselect it rkwriter Windows XP General 3 17th Aug 2009 12:52 AM
Deselect / Deactivate a selected picture Henk Microsoft Excel Programming 2 3rd Feb 2009 09:54 PM
how can I deselect one of the multiple selected rows? jopieb123 Microsoft Excel Misc 3 1st Dec 2005 04:50 PM
Deselect one of many non-adjacent rows selected =?Utf-8?B?Tmljb2xsZSBLLg==?= Microsoft Excel Misc 1 11th Jan 2005 07:24 PM
Deselect two objects after all selected Cutter Microsoft Excel Programming 3 8th Aug 2004 03:53 AM


Features
 

Advertising
 

Newsgroups
 


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