ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Proper way to call/pass excel.shape as a parameter? (https://www.excelbanter.com/excel-programming/414718-proper-way-call-pass-excel-shape-parameter.html)

Ker_01

Proper way to call/pass excel.shape as a parameter?
 
Still working on a toolbar add-in for a project. I searched and found a few
methods for assigning a transparency mask in XL2003, which would be a nice
feature (makes the buttons look better). I'm trying to use a method provided
by KeepItCool in 2005, because I don't have an image editor on my work PC
that would allow me to change the transparency flag of my icons.

source:
http://www.tech-archive.net/Archive/.../msg05807.html

KeepItCool's procedure requires the passing of the following parameters:

Sub SetIcon(ByVal oBtn As Office.CommandBarButton, _
ByVal shpIcon As Excel.Shape, _
ByVal shpMask As Excel.Shape)

I'm having trouble figuring out the syntax to pass the Excel.shapes that I
have pasted on my worksheet, e.g.

For example,

frontface = ActiveSheet.DrawingObjects("ShowAllShifts")
maskface = ActiveSheet.DrawingObjects("mask2")
SetIcon(Newbtn, FrontFace, maskface)

or

Dim frontface As Excel.Shape
Set frontface = Sheet1.DrawingObjects("ShowAllShifts")
'etc

Can anyone tell me how to pass (by name) the icons on my sheet as
Excel.shape?
Thanks!
Keith



Gary''s Student

Proper way to call/pass excel.shape as a parameter?
 
Let's say we have shapes on a sheet and one of the shapes is named:
Rectangle 2
The following code passes the name of the shape as a string:

Sub main()
Dim shapename As String
shapename = "Rectangle 2"
Call routine(shapename)
End Sub

Sub routine(which_one As String)
ActiveSheet.Shapes(which_one).Select
End Sub


--
Gary''s Student - gsnu2007j

Ker_01

Proper way to call/pass excel.shape as a parameter?
 
Thanks Gary''s Student-

After much stress and hair-pulling, I got it working; it turns out that
while my syntax worked before I started using KeepItCool's procedure, the
way I was 'capturing' the shape reference was no longer valid. I was
originally using .DrawingObjects in an earlier version of my toolbar macro
(and it was working for how I was using it), but to pass the value to this
new procedure I had to use .shape; once I switched to
Sheet1.Shapes("shapename") it all worked just fine.

Thanks!
Keith

"Gary''s Student" wrote in message
...
Let's say we have shapes on a sheet and one of the shapes is named:
Rectangle 2
The following code passes the name of the shape as a string:

Sub main()
Dim shapename As String
shapename = "Rectangle 2"
Call routine(shapename)
End Sub

Sub routine(which_one As String)
ActiveSheet.Shapes(which_one).Select
End Sub


--
Gary''s Student - gsnu2007j





All times are GMT +1. The time now is 05:39 PM.

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