L
Luca Brasi
My add-in should process all charts the user currently has selected. Now I
ran into a problem when the user has selected several charts (but not all!)
on a worksheet.
It looks to me as if there is a bug in the "Selection" object in Excel 2007.
Let's say I select two out of three charts on a worksheet and run the sample
code below. Instead of the selected charts, the first two charts I inserted
into the worksheet are processed.
Am I doing something wrong or can someone confirm this is a bug in Excel
2007? Knows someone a workaround? Thanks for any hints, Luca
'*** Sample code
Sub Test()
Dim i As Long
Dim obj As Object
If Windows.Count > 0 Then
If TypeName(ActiveSheet) = "Worksheet" Then
If TypeName(ActiveWindow.Selection) = "DrawingObjects" Then
For i = 1 To ActiveWindow.Selection.Count
Set obj = ActiveWindow.Selection(i)
If TypeName(obj) = "ChartObject" Then
' toggle legend to show which charts are processed
obj.Chart.SetElement IIf(obj.Chart.HasLegend, _
msoElementLegendNone, msoElementLegendBottom)
End If
Next i
End If
End If
End If
End Sub
'*** End of code
ran into a problem when the user has selected several charts (but not all!)
on a worksheet.
It looks to me as if there is a bug in the "Selection" object in Excel 2007.
Let's say I select two out of three charts on a worksheet and run the sample
code below. Instead of the selected charts, the first two charts I inserted
into the worksheet are processed.
Am I doing something wrong or can someone confirm this is a bug in Excel
2007? Knows someone a workaround? Thanks for any hints, Luca
'*** Sample code
Sub Test()
Dim i As Long
Dim obj As Object
If Windows.Count > 0 Then
If TypeName(ActiveSheet) = "Worksheet" Then
If TypeName(ActiveWindow.Selection) = "DrawingObjects" Then
For i = 1 To ActiveWindow.Selection.Count
Set obj = ActiveWindow.Selection(i)
If TypeName(obj) = "ChartObject" Then
' toggle legend to show which charts are processed
obj.Chart.SetElement IIf(obj.Chart.HasLegend, _
msoElementLegendNone, msoElementLegendBottom)
End If
Next i
End If
End If
End If
End Sub
'*** End of code