Using shapes as opposed CommandButtons

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
Morning,
I always use active X controls but unable to get a code working with one.
If i use a shape then what i want to happens works.

My question is how do i go about taking code from Active X control & using it on a shape,or am i going to run into problems.


This works for me.
Rich (BB code):
Sub test()
With ThisWorkbook
With .sheets(.sheets.Count)
.Shapes("Rectangle 1").Visible = msoFalse
.Shapes("Rectangle 2").Visible = msoFalse
.Shapes("Rectangle 3").Visible = msoFalse
End With
End With
End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Dim Shape As Shape
For Each Shape In ActiveSheet.shapes
If Shape.Name <> "PrintGeneratedSheet" Then
Shape.Visible = False
End If
Next
 
Upvote 0
My apologies, I looked at your code and misread the question...🫣
 
Upvote 0
It seems impossible to give a comprehensive answer due to the properties of different ActiveX objects.

For example, Button, Shape, and CommandButton generally work the same way. You click and the macro starts.

The biggest (tiny) difference is that you have to define a macro to be executed for Button and Shape.
When creating a CommandButton, an empty macro is automatically created in the worksheet module.
 
Upvote 0
Something like this...

1. Copy the ActiveX code.
2. Paste the copied code into the regular VBAProject module.
3. Rename Private Sub CommandButton1_Click() For example, Sub CopyINV_G13toDATA_A10()
4. Create a Shape
5. Shape Right Click -> Assign Macro
6. Select CopyINV_G13toDATA_A10
OR
7. Select New -> new Sub is created
AND
8. Add line: Call CopyINV_G13toDATA_A10
*. You can of course do step 7 and copy the AxtiveX code directly into the created Sub
 
Upvote 0
You didn't ask this, but "I always use active X controls but unable to get a code working with one." which one active X controls doesn't work?
Does it belong to your "TEST FILE.xlsm" file?
 
Upvote 0

Forum statistics

Threads
1,215,160
Messages
6,123,355
Members
449,097
Latest member
thnirmitha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top