H
Hiran de Silva
I have an Excel 2000 workbook that creates a set of square shapes, which are
named 'ButtonNNN' where NNN is a number eg. 013. When clicked they are
supposed to fire off a macro and pass the parameter indicated by the NNN -
ie. 13 in this example.
This works fine. But on a few PCs the macro does not get fired off; nothing
happens. Can someone tell me why?
Here is my code, and a simplified test workbook can be downloaded here.
http://www.askhiran.com/excel/expandtroubleshoot.xls
Sub CreateSquares()
For i = 1 To 5
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 1, 1, 20#,
20#).Select
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Line.Visible = msoTrue
Selection.ShapeRange.Name = "Button" +
Excel.WorksheetFunction.Text(i, "000")
'this is an undocumented Excel VBA syntax! see Tom Ogilvy Jan
20, 2003. Thanks Tom.
'eg. Selection.OnAction = "'ExpandSummarise 10'"
strAction = "'ExpandSummarise " + Trim(Str(i)) + "'"
Selection.OnAction = strAction
'show expand buttons
strButtonName = "Button" + Excel.WorksheetFunction.Text(i,
"000")
ActiveSheet.Shapes(strButtonName).Left = 200
ActiveSheet.Shapes(strButtonName).Top = (i * 30 + 5) + 75
ActiveSheet.Shapes(strButtonName).Fill.ForeColor.SchemeColor
= 51
ActiveSheet.Shapes(strButtonName).Fill.Visible = msoTrue
ActiveSheet.Shapes(strButtonName).Line.Visible = msoFalse
Next i
Range("A1").Select
End Sub
Sub ExpandSummarise(intLineToExpand As Integer)
'Debug code
MsgBox intLineToExpand
End Sub
Thanks,
Hiran
named 'ButtonNNN' where NNN is a number eg. 013. When clicked they are
supposed to fire off a macro and pass the parameter indicated by the NNN -
ie. 13 in this example.
This works fine. But on a few PCs the macro does not get fired off; nothing
happens. Can someone tell me why?
Here is my code, and a simplified test workbook can be downloaded here.
http://www.askhiran.com/excel/expandtroubleshoot.xls
Sub CreateSquares()
For i = 1 To 5
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 1, 1, 20#,
20#).Select
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Line.Visible = msoTrue
Selection.ShapeRange.Name = "Button" +
Excel.WorksheetFunction.Text(i, "000")
'this is an undocumented Excel VBA syntax! see Tom Ogilvy Jan
20, 2003. Thanks Tom.
'eg. Selection.OnAction = "'ExpandSummarise 10'"
strAction = "'ExpandSummarise " + Trim(Str(i)) + "'"
Selection.OnAction = strAction
'show expand buttons
strButtonName = "Button" + Excel.WorksheetFunction.Text(i,
"000")
ActiveSheet.Shapes(strButtonName).Left = 200
ActiveSheet.Shapes(strButtonName).Top = (i * 30 + 5) + 75
ActiveSheet.Shapes(strButtonName).Fill.ForeColor.SchemeColor
= 51
ActiveSheet.Shapes(strButtonName).Fill.Visible = msoTrue
ActiveSheet.Shapes(strButtonName).Line.Visible = msoFalse
Next i
Range("A1").Select
End Sub
Sub ExpandSummarise(intLineToExpand As Integer)
'Debug code
MsgBox intLineToExpand
End Sub
Thanks,
Hiran