Creating a button and assigning macro

P

Pasha

Within a macro, I am creating a button that will execute another macro:
ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1"
Link:=False _
, DisplayAsIcon:=False, Left:=18, Top:=12.75, Width:=64.5
Height:= _
15.75).Select

How do I:

1. Change the caption of this button to "Print"?
2. Assign Macro "Print" to this button?

Any ideas
 
B

Bob Phillips

It's easier with a Forms button

Application.CommandBars("Forms").Visible = True
ActiveSheet.Buttons.Add(18, 12.75, 64.5, 15.75).Select
Selection.Caption = "Print"
Selection.OnAction = "myPrintMacro"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top