View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jacob Jacob is offline
external usenet poster
 
Posts: 26
Default Assign code to shape

Hi,
I have an application which addss a bar chart to a new
workbook, adds a scroll bar to the chart and then assign
code to the scrollbar shape. The code assigned is written
on fly and placed in a general code module. When
executing the assignment with the following code I get an
error on the .OnAction statement (1004)

Charts(PlotName).Activate
Charts(PlotName).Shapes("Scroll Bar 1").Select
With Selection
.Value = 3
.Min = 3
.Max = Tpoints + 2
.SmallChange = 1
.LargeChange = Application.WorksheetFunction. _
Max(1, Tpoints / 500)
.Display3DShading = True
.Name = "scb_" & PlotName
.OnAction = SelectedBooks(0) & _
"!ScrollBarTime" & PlotName
End With

If, in the .OnAction statement, I do not qualify the name
of the sub with the workbook name where the code resides
I do not get an error, but the shape object can't find
the code as VBA has qualified it with the addin book
name. Is there a way around this?

Any help appreciated