Testing if chart is selected

Dexter666

New Member
Joined
May 28, 2009
Messages
31
Hi, I have a small sub for (un)rounding the corners of selected charts... But if no chart is selected the procedure shows an error message (91). The Err.Number = 91 won't catch up the error. Is there any other way to test if a chart (object) is selected, so i can get a Message "No chart selected". Thanks

Code:
 Sub zaobli_graf()
 Dim cbo As ChartObject
 Dim cht As Chart
 Dim menoGrafu As String
  
        menoGrafu = ActiveChart.Parent.Name
        Set cbo = ActiveSheet.ChartObjects(menoGrafu)
        Set cht = cbo.Chart
        cbo.RoundedCorners = cbo.RoundedCorners = False

 End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try

Code:
Sub zaobli_graf()
 Dim cbo As ChartObject
 Dim cht As Chart
 Dim menoGrafu As String
If ActiveChart Is Nothing Then Exit Sub
  
        menoGrafu = ActiveChart.Parent.Name
        Set cbo = ActiveSheet.ChartObjects(menoGrafu)
        Set cht = cbo.Chart
        cbo.RoundedCorners = cbo.RoundedCorners = False

 End Sub
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top