Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro not firing off

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.S chemeColor
= 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





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro not firing off

I don't open attachments or open other files. But your code worked fine for me.

Is there a chance that the others have disabled macros when they opened your
workbook?

And this makes absolutely no difference to your problem, but you can add those
rectangles without selecting the shapes:

Option Explicit
Sub CreateSquares()
Dim myRect As Rectangle
Dim i As Long
Dim strAction As String
Dim myName As String

For i = 1 To 5
myName = "Button" & Format(i, "000")
On Error Resume Next
ActiveSheet.Rectangles(myName).Delete
On Error GoTo 0
Set myRect = ActiveSheet.Rectangles.Add(0, 0, 0, 0)
With myRect
.Name = myName
'this is an undocumented Excel VBA syntax!
'see Tom Ogilvy Jan 20, 2003. Thanks Tom.
'eg. Selection.OnAction = "'ExpandSummarise 10'"
strAction = "'ExpandSummarise " & i & "'"
.OnAction = strAction
.Left = 200
.Top = (i * 30 + 5) + 75
.Width = 20
.Height = 20
.ShapeRange.Fill.Visible = msoTrue
.ShapeRange.Line.Visible = msoTrue
.ShapeRange.Fill.ForeColor.SchemeColor = 51
.ShapeRange.Fill.Visible = msoTrue
.ShapeRange.Line.Visible = msoFalse
End With
Next i

End Sub

Sub ExpandSummarise(intLineToExpand As Integer)
'Debug code
MsgBox intLineToExpand
End Sub




Hiran de Silva wrote:

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.S chemeColor
= 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


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro not firing off

Thanks Dave. Macros are turned on (for the two users who have this problem).
It works for everyone else. Same version/build of Excel 2000.
A further clue is these two users are on laptops, but that shouldn't make
any difference I thought.

Thanks for any further ideas.

Hiran



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro not firing off

I don't have any guess why the macros aren't being called. Maybe the user can
rightclick on the rectangle and see what macro (if anything) is assigned to it.

Hiran de Silva wrote:

Thanks Dave. Macros are turned on (for the two users who have this problem).
It works for everyone else. Same version/build of Excel 2000.
A further clue is these two users are on laptops, but that shouldn't make
any difference I thought.

Thanks for any further ideas.

Hiran


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I test if a Macro if firing? ZZBC Excel Worksheet Functions 6 January 31st 06 03:09 AM
Event macro firing twice Otto Moehrbach Excel Programming 10 July 6th 05 11:57 PM
Workbook_Open event not firing 0013 Excel Programming 4 May 24th 05 09:53 PM
Event sometimes stops firing? HotRod Excel Programming 7 May 5th 05 12:20 AM
Multiple firing of macro from ListBox SteveF Excel Programming 2 December 9th 04 08:21 AM


All times are GMT +1. The time now is 11:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"