Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
command button
Hello,
Is it possible to use a macro to create a command button, which would run an additional at the users request. Let me know if you need more info. Thank You, |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
command button
I'm not sure what you mean by "run an additional", but here's a macro
I've used to put a Forms command button (Forms) on the worksheet, and open the assign macro dialog to allow the user to assign a macro, and labels the button with the macro name. Public Sub AddButtonToSheet() 'J.E. McGimpsey 2001-10-13 'Put Forms Command Button on sheet, Format it, 'and assign a macro to it. Dim oOldSelection As Object Dim rOldActive As Range Dim sCaption As String Set oOldSelection = Selection If TypeName(oOldSelection) = "Range" Then _ Set rOldActive = ActiveCell Application.ScreenUpdating = False With ActiveSheet.Shapes.AddFormControl( _ xlButtonControl, 600, 50, 1, 23) .ControlFormat.PrintObject = False With .TextFrame.Characters.Font .Name = "Verdana" .FontStyle = "Bold" .Size = 12 .ColorIndex = 13 .Shadow = False End With .Select Application.Dialogs(xlDialogAssignToObject).Show "try" sCaption = .OnAction If Len(sCaption) 0 Then _ Selection.Caption = Mid(sCaption, InStr(sCaption, "!") + 1) Selection.AutoSize = True End With oOldSelection.Select If Not rOldActive Is Nothing Then rOldActive.Activate Application.ScreenUpdating = True End Sub In article , tjh wrote: Hello, Is it possible to use a macro to create a command button, which would run an additional at the users request. Let me know if you need more info. Thank You, |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
command button
Yes, this is exactly what I need. The only change is rather than allowing the
user to assign the macro to run, I would like to place the macro in the code. So that if the user hits the button it will run the macro that I have assigned. Having a little trouble with the change, where should I place this code with in yours?: ActiveSheet.Shapes("Button 1").Select Selection.OnAction = "Macro1" "JE McGimpsey" wrote: I'm not sure what you mean by "run an additional", but here's a macro I've used to put a Forms command button (Forms) on the worksheet, and open the assign macro dialog to allow the user to assign a macro, and labels the button with the macro name. Public Sub AddButtonToSheet() 'J.E. McGimpsey 2001-10-13 'Put Forms Command Button on sheet, Format it, 'and assign a macro to it. Dim oOldSelection As Object Dim rOldActive As Range Dim sCaption As String Set oOldSelection = Selection If TypeName(oOldSelection) = "Range" Then _ Set rOldActive = ActiveCell Application.ScreenUpdating = False With ActiveSheet.Shapes.AddFormControl( _ xlButtonControl, 600, 50, 1, 23) .ControlFormat.PrintObject = False With .TextFrame.Characters.Font .Name = "Verdana" .FontStyle = "Bold" .Size = 12 .ColorIndex = 13 .Shadow = False End With .Select Application.Dialogs(xlDialogAssignToObject).Show "try" sCaption = .OnAction If Len(sCaption) 0 Then _ Selection.Caption = Mid(sCaption, InStr(sCaption, "!") + 1) Selection.AutoSize = True End With oOldSelection.Select If Not rOldActive Is Nothing Then rOldActive.Activate Application.ScreenUpdating = True End Sub In article , tjh wrote: Hello, Is it possible to use a macro to create a command button, which would run an additional at the users request. Let me know if you need more info. Thank You, |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
command button
Got it, nevermind.
Thank You for your help!!!!!! "tjh" wrote: Hello, Is it possible to use a macro to create a command button, which would run an additional at the users request. Let me know if you need more info. Thank You, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
command button add another command | Excel Discussion (Misc queries) | |||
Command button | Excel Discussion (Misc queries) | |||
Command Button | Excel Worksheet Functions | |||
Command Button vs Control Button | Excel Programming | |||
Command Button vs Form Button | Excel Programming |