how to Hide/delete dynamically created button?

H

HammerJoe

Hi,

I have a macro that automatically creates a new sheet and creates a
button in it so user can get out of it.
(the idea is that this sheet will be emailed and I wanted to remove
all formulas and leave just the format and numbers.

this is the code that I use to create the button:

Set btn = NewWs.Buttons.Add(65.25, 552.75, 296.25, 32.25)
btn.Select
Selection.Characters.Text = "[...DONE...]"
With Selection
.Font.Name = "Arial"
.Font.FontStyle = "Bold"
.Font.Size = 10
.Font.ColorIndex = xlAutomatic
.Locked = True
.LockedText = True
.Name = "Done"
End With
btn.OnAction = "CommandButtonSendEmailOK"
End With


It works fine.
Now, How do I hide/delete this button afterwards?
I though I could use the .NAME to reference it but obviously it doesnt
work.

When the recepient of the email opens the sheet I dont want to have
the button available.

Please help me.
Thanks
 
J

Jim Rech

NewWS.Buttons("Done").Visible = False

Technically it's not a command button, being from the Forms toolbar instead
of the Control Toolbox.

--
Jim
| Hi,
|
| I have a macro that automatically creates a new sheet and creates a
| button in it so user can get out of it.
| (the idea is that this sheet will be emailed and I wanted to remove
| all formulas and leave just the format and numbers.
|
| this is the code that I use to create the button:
|
| Set btn = NewWs.Buttons.Add(65.25, 552.75, 296.25, 32.25)
| btn.Select
| Selection.Characters.Text = "[...DONE...]"
| With Selection
| .Font.Name = "Arial"
| .Font.FontStyle = "Bold"
| .Font.Size = 10
| .Font.ColorIndex = xlAutomatic
| .Locked = True
| .LockedText = True
| .Name = "Done"
| End With
| btn.OnAction = "CommandButtonSendEmailOK"
| End With
|
|
| It works fine.
| Now, How do I hide/delete this button afterwards?
| I though I could use the .NAME to reference it but obviously it doesnt
| work.
|
| When the recepient of the email opens the sheet I dont want to have
| the button available.
|
| Please help me.
| Thanks
 

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