![]() |
Programming code to new object
I want to create button with some code to worksheet. I can programm button
but i don't know how can i do action for this button :-(. Do you know please? |
Programming code to new object
See other post.
-- HTH Bob Phillips "Martin" wrote in message ... I want to create button with some code to worksheet. I can programm button but i don't know how can i do action for this button :-(. Do you know please? |
Programming code to new object
Hi Martin,
Try: ActiveSheet.Buttons("Button 1").OnAction = "MyMacro" --- Regards, Norman "Martin" wrote in message ... I want to create button with some code to worksheet. I can programm button but i don't know how can i do action for this button :-(. Do you know please? |
Programming code to new object
Thank you, but it doesn't work :-(. It show me warning: "Can't get button
property worksheet class". For illustration, there is program: ActiveSheet.OLEObjects.Add ClassType:="Forms.CommandButton.1", Link:=False, DisplayAsIcon:=False, Left:=521.25, Top:=174, Width:=253.5, Height:=34.5 ActiveSheet.OLEObjects("CommandButton1").Object.Ca ption = "Návrat" ActiveSheet.Buttons("CommandButton1").OnAction = "NavratZpet" "Norman Jones" wrote: Hi Martin, Try: ActiveSheet.Buttons("Button 1").OnAction = "MyMacro" --- Regards, Norman "Martin" wrote in message ... I want to create button with some code to worksheet. I can programm button but i don't know how can i do action for this button :-(. Do you know please? |
Programming code to new object
Hi, thank you but it doesn't work, it shows me warning:"Can't get button
property of worksheet class". Do you know where i make mistake? ActiveSheet.OLEObjects.Add ClassType:="Forms.CommandButton.1", Link:=False, DisplayAsIcon:=False, Left:=521.25, Top:=174, Width:=253.5, Height:=34.5 ActiveSheet.OLEObjects("CommandButton1").Object.Ca ption = "Návrat" ActiveSheet.Buttons("CommandButton1").OnAction = "NavratZpet" "Norman Jones" wrote: Hi Martin, Try: ActiveSheet.Buttons("Button 1").OnAction = "MyMacro" --- Regards, Norman "Martin" wrote in message ... I want to create button with some code to worksheet. I can programm button but i don't know how can i do action for this button :-(. Do you know please? |
Programming code to new object
Hi Martim.
Your problem is that you are not using a button from the Forms toolbar but a CommandButton from the Controls Toolbox. In the relevant worksheet module (right-click the worksheet tab | View Code), paste the following: Private Sub CommandButton1_Click() 'Your macro code here End Sub --- Regards, Norman "Martin" wrote in message ... Hi, thank you but it doesn't work, it shows me warning:"Can't get button property of worksheet class". Do you know where i make mistake? ActiveSheet.OLEObjects.Add ClassType:="Forms.CommandButton.1", Link:=False, DisplayAsIcon:=False, Left:=521.25, Top:=174, Width:=253.5, Height:=34.5 ActiveSheet.OLEObjects("CommandButton1").Object.Ca ption = "Návrat" ActiveSheet.Buttons("CommandButton1").OnAction = "NavratZpet" "Norman Jones" wrote: Hi Martin, Try: ActiveSheet.Buttons("Button 1").OnAction = "MyMacro" --- Regards, Norman "Martin" wrote in message ... I want to create button with some code to worksheet. I can programm button but i don't know how can i do action for this button :-(. Do you know please? |
Programming code to new object
Hi Martin,
See your other post. --- Regards, Norman "Martin" wrote in message ... Thank you, but it doesn't work :-(. It show me warning: "Can't get button property worksheet class". For illustration, there is program: ActiveSheet.OLEObjects.Add ClassType:="Forms.CommandButton.1", Link:=False, DisplayAsIcon:=False, Left:=521.25, Top:=174, Width:=253.5, Height:=34.5 ActiveSheet.OLEObjects("CommandButton1").Object.Ca ption = "Návrat" ActiveSheet.Buttons("CommandButton1").OnAction = "NavratZpet" "Norman Jones" wrote: Hi Martin, Try: ActiveSheet.Buttons("Button 1").OnAction = "MyMacro" --- Regards, Norman "Martin" wrote in message ... I want to create button with some code to worksheet. I can programm button but i don't know how can i do action for this button :-(. Do you know please? |
Programming code to new object
If it is a forms button, just right-click it and assign a macro from the
menu options. -- HTH Bob Phillips "Martin" wrote in message ... Hi, thank you but it doesn't work, it shows me warning:"Can't get button property of worksheet class". Do you know where i make mistake? ActiveSheet.OLEObjects.Add ClassType:="Forms.CommandButton.1", Link:=False, DisplayAsIcon:=False, Left:=521.25, Top:=174, Width:=253.5, Height:=34.5 ActiveSheet.OLEObjects("CommandButton1").Object.Ca ption = "Návrat" ActiveSheet.Buttons("CommandButton1").OnAction = "NavratZpet" "Norman Jones" wrote: Hi Martin, Try: ActiveSheet.Buttons("Button 1").OnAction = "MyMacro" --- Regards, Norman "Martin" wrote in message ... I want to create button with some code to worksheet. I can programm button but i don't know how can i do action for this button :-(. Do you know please? |
Programming code to new object
Thank you very much! Can i have last question? Can I change caption of button?
It is worst: ActiveSheet.Buttons("Button 1").Caption = "Back" "Norman Jones" wrote: Hi Martim. Your problem is that you are not using a button from the Forms toolbar but a CommandButton from the Controls Toolbox. In the relevant worksheet module (right-click the worksheet tab | View Code), paste the following: Private Sub CommandButton1_Click() 'Your macro code here End Sub --- Regards, Norman "Martin" wrote in message ... Hi, thank you but it doesn't work, it shows me warning:"Can't get button property of worksheet class". Do you know where i make mistake? ActiveSheet.OLEObjects.Add ClassType:="Forms.CommandButton.1", Link:=False, DisplayAsIcon:=False, Left:=521.25, Top:=174, Width:=253.5, Height:=34.5 ActiveSheet.OLEObjects("CommandButton1").Object.Ca ption = "Návrat" ActiveSheet.Buttons("CommandButton1").OnAction = "NavratZpet" "Norman Jones" wrote: Hi Martin, Try: ActiveSheet.Buttons("Button 1").OnAction = "MyMacro" --- Regards, Norman "Martin" wrote in message ... I want to create button with some code to worksheet. I can programm button but i don't know how can i do action for this button :-(. Do you know please? |
Programming code to new object
Hi Martin,
You have already provided the code to name (or rename) the button yourself: ActiveSheet.OLEObjects("CommandButton1").Object.Ca ption _ = "Návrat" --- Regards, Norman "Martin" wrote in message ... Thank you very much! Can i have last question? Can I change caption of button? It is worst: ActiveSheet.Buttons("Button 1").Caption = "Back" "Norman Jones" wrote: Hi Martim. Your problem is that you are not using a button from the Forms toolbar but a CommandButton from the Controls Toolbox. In the relevant worksheet module (right-click the worksheet tab | View Code), paste the following: Private Sub CommandButton1_Click() 'Your macro code here End Sub --- Regards, Norman "Martin" wrote in message ... Hi, thank you but it doesn't work, it shows me warning:"Can't get button property of worksheet class". Do you know where i make mistake? ActiveSheet.OLEObjects.Add ClassType:="Forms.CommandButton.1", Link:=False, DisplayAsIcon:=False, Left:=521.25, Top:=174, Width:=253.5, Height:=34.5 ActiveSheet.OLEObjects("CommandButton1").Object.Ca ption = "Návrat" ActiveSheet.Buttons("CommandButton1").OnAction = "NavratZpet" "Norman Jones" wrote: Hi Martin, Try: ActiveSheet.Buttons("Button 1").OnAction = "MyMacro" --- Regards, Norman "Martin" wrote in message ... I want to create button with some code to worksheet. I can programm button but i don't know how can i do action for this button :-(. Do you know please? |
Programming code to new object
Hi Martin,
Word-wrap willing: ActiveSheet.OLEObjects _ ("CommandButton1").Object.Caption = "Návrat" --- Regards, Norman "Norman Jones" wrote in message ... Hi Martin, You have already provided the code to name (or rename) the button yourself: ActiveSheet.OLEObjects("CommandButton1").Object.Ca ption _ = "Návrat" --- Regards, Norman "Martin" wrote in message ... Thank you very much! Can i have last question? Can I change caption of button? It is worst: ActiveSheet.Buttons("Button 1").Caption = "Back" "Norman Jones" wrote: Hi Martim. Your problem is that you are not using a button from the Forms toolbar but a CommandButton from the Controls Toolbox. In the relevant worksheet module (right-click the worksheet tab | View Code), paste the following: Private Sub CommandButton1_Click() 'Your macro code here End Sub --- Regards, Norman "Martin" wrote in message ... Hi, thank you but it doesn't work, it shows me warning:"Can't get button property of worksheet class". Do you know where i make mistake? ActiveSheet.OLEObjects.Add ClassType:="Forms.CommandButton.1", Link:=False, DisplayAsIcon:=False, Left:=521.25, Top:=174, Width:=253.5, Height:=34.5 ActiveSheet.OLEObjects("CommandButton1").Object.Ca ption = "Návrat" ActiveSheet.Buttons("CommandButton1").OnAction = "NavratZpet" "Norman Jones" wrote: Hi Martin, Try: ActiveSheet.Buttons("Button 1").OnAction = "MyMacro" --- Regards, Norman "Martin" wrote in message ... I want to create button with some code to worksheet. I can programm button but i don't know how can i do action for this button :-(. Do you know please? |
Programming code to new object
Hi Norman,
thank you for all! I haven't another question ;-) Regards Martin "Norman Jones" wrote: Hi Martin, Word-wrap willing: ActiveSheet.OLEObjects _ ("CommandButton1").Object.Caption = "Návrat" --- Regards, Norman "Norman Jones" wrote in message ... Hi Martin, You have already provided the code to name (or rename) the button yourself: ActiveSheet.OLEObjects("CommandButton1").Object.Ca ption _ = "Návrat" --- Regards, Norman "Martin" wrote in message ... Thank you very much! Can i have last question? Can I change caption of button? It is worst: ActiveSheet.Buttons("Button 1").Caption = "Back" "Norman Jones" wrote: Hi Martim. Your problem is that you are not using a button from the Forms toolbar but a CommandButton from the Controls Toolbox. In the relevant worksheet module (right-click the worksheet tab | View Code), paste the following: Private Sub CommandButton1_Click() 'Your macro code here End Sub --- Regards, Norman "Martin" wrote in message ... Hi, thank you but it doesn't work, it shows me warning:"Can't get button property of worksheet class". Do you know where i make mistake? ActiveSheet.OLEObjects.Add ClassType:="Forms.CommandButton.1", Link:=False, DisplayAsIcon:=False, Left:=521.25, Top:=174, Width:=253.5, Height:=34.5 ActiveSheet.OLEObjects("CommandButton1").Object.Ca ption = "Návrat" ActiveSheet.Buttons("CommandButton1").OnAction = "NavratZpet" "Norman Jones" wrote: Hi Martin, Try: ActiveSheet.Buttons("Button 1").OnAction = "MyMacro" --- Regards, Norman "Martin" wrote in message ... I want to create button with some code to worksheet. I can programm button but i don't know how can i do action for this button :-(. Do you know please? |
Programming code to new object
Hi Martin,
thank you for all! I haven't another question ;-) Je t'en prie! --- Regards, Norman "Martin" wrote in message ... Hi Norman, thank you for all! I haven't another question ;-) Regards Martin "Norman Jones" wrote: Hi Martin, Word-wrap willing: ActiveSheet.OLEObjects _ ("CommandButton1").Object.Caption = "Návrat" --- Regards, Norman "Norman Jones" wrote in message ... Hi Martin, You have already provided the code to name (or rename) the button yourself: ActiveSheet.OLEObjects("CommandButton1").Object.Ca ption _ = "Návrat" --- Regards, Norman "Martin" wrote in message ... Thank you very much! Can i have last question? Can I change caption of button? It is worst: ActiveSheet.Buttons("Button 1").Caption = "Back" "Norman Jones" wrote: Hi Martim. Your problem is that you are not using a button from the Forms toolbar but a CommandButton from the Controls Toolbox. In the relevant worksheet module (right-click the worksheet tab | View Code), paste the following: Private Sub CommandButton1_Click() 'Your macro code here End Sub --- Regards, Norman "Martin" wrote in message ... Hi, thank you but it doesn't work, it shows me warning:"Can't get button property of worksheet class". Do you know where i make mistake? ActiveSheet.OLEObjects.Add ClassType:="Forms.CommandButton.1", Link:=False, DisplayAsIcon:=False, Left:=521.25, Top:=174, Width:=253.5, Height:=34.5 ActiveSheet.OLEObjects("CommandButton1").Object.Ca ption = "Návrat" ActiveSheet.Buttons("CommandButton1").OnAction = "NavratZpet" "Norman Jones" wrote: Hi Martin, Try: ActiveSheet.Buttons("Button 1").OnAction = "MyMacro" --- Regards, Norman "Martin" wrote in message ... I want to create button with some code to worksheet. I can programm button but i don't know how can i do action for this button :-(. Do you know please? |
All times are GMT +1. The time now is 01:25 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com