ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Assign code to shape (https://www.excelbanter.com/excel-programming/281428-assign-code-shape.html)

Jacob

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

Jacob

Assign code to shape
 
Forget this one,
Sorry bout it but I'd forgotten to check for forbidden
charcters in the book name.
-----Original Message-----
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
.



All times are GMT +1. The time now is 10:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com