Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I have recorded a macro that creates a button, assigns a macro and positions the button. In my spreadsheet application it is often necessary to destroy objects and if I run the macro again to recreate the button, I get a Run_time error saying that the item with the specified name wasn't found. I understand why it is happening, but don't know what the workaround can be, bearing in mind that I will need to frequently destroy the button and recreate it. Can one force the button to be created with a specific name? Can anyone help? My code is below; Sub BuildButton() ActiveSheet.Buttons.Add(4.5, 3, 72, 72).Select Selection.OnAction = "Connect2Servers" ActiveSheet.Shapes("Button 1").Select Selection.Characters.Text = "Connect to Servers" With Selection.Characters(Start:=1, Length:=18).Font .Name = "Arial" .FontStyle = "Regular" .Size = 10 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic End With Selection.ShapeRange.ScaleWidth 2.19, msoFalse, msoScaleFromTopLeft Selection.ShapeRange.IncrementTop -0.75 Selection.ShapeRange.IncrementTop -0.75 Selection.ShapeRange.IncrementTop -0.75 Selection.ShapeRange.IncrementTop -0.75 Selection.ShapeRange.IncrementLeft -0.75 Selection.ShapeRange.IncrementLeft -0.75 Selection.ShapeRange.IncrementLeft -0.75 Selection.ShapeRange.IncrementLeft -0.75 Selection.ShapeRange.IncrementLeft -0.75 Selection.ShapeRange.IncrementLeft -0.75 Selection.ShapeRange.IncrementLeft -0.75 Selection.ShapeRange.IncrementTop -0.75 End Sub Many Thanks - Grant |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Assigning a macro to a button | Excel Worksheet Functions | |||
Assigning A Macro to A Button | Excel Worksheet Functions | |||
Help in assigning a command button | Excel Discussion (Misc queries) | |||
assigning macro to button | Excel Discussion (Misc queries) | |||
Assigning macro to button | Excel Discussion (Misc queries) |