Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default 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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default 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?




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default 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?






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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?






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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?






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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?






  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default 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?






  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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?










  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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?










  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default 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?











  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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?













Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete object code Marie Bayes Excel Discussion (Misc queries) 1 April 29th 09 03:41 PM
Chart Object VB Code MS[_2_] Charts and Charting in Excel 2 March 6th 07 11:41 AM
programming VBE - Deleting All Code From A Module pm Excel Discussion (Misc queries) 4 December 31st 05 01:21 AM
HELP! Object specific Code dee Excel Programming 3 February 13th 05 07:16 PM


All times are GMT +1. The time now is 01:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"