generate textbox on button click

lyntan

New Member
Joined
Sep 14, 2015
Messages
19
hello! please help!
how to generate textbox on button click?
i got this code :
ActiveSheet.Shapes.AddLabel(msoTextOrientationHorizontal, 2800, 900, 100, 30).Select

it works but its a plain box without background colour or border.
i need a coloured textbox on button click in excel.
please help ;( :(
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I suggest you Run the Macro Recorder and make the Text Box exactly the way you want. Move the text box and next time you want another text box just run the script.
 
Upvote 0
On your ribbon click on view. Look on right and you should see Macros. Choose Record Macro. Now there is a recorder that will record every thing you do. When done click macros and choose Stop. Then you can assign this macro to a button to run it. I'm surprised you know how to write install and run scripts but are not familiar with the recorder. Check back if you do not understand me.
 
Upvote 0
On your ribbon click on view. Look on right and you should see Macros. Choose Record Macro. Now there is a recorder that will record every thing you do. When done click macros and choose Stop. Then you can assign this macro to a button to run it. I'm surprised you know how to write install and run scripts but are not familiar with the recorder. Check back if you do not understand me.

oh yes! it works! when i click the button the coloured text box appeared ! thank you!
but it only works once.
when i click the button again it shows error.
 
Upvote 0
You ran the recorder and made you box. You stopped the recorder. And then assigned the script to a button and it ran once but the second time it errored out is that what your saying. Try running the script from the view Macro run Macro on the ribbon and see if it works OK
 
Upvote 0
You ran the recorder and made you box. You stopped the recorder. And then assigned the script to a button and it ran once but the second time it errored out is that what your saying. Try running the script from the view Macro run Macro on the ribbon and see if it works OK

'object does not support this property or method'
 
Upvote 0
I would suggest running the recorder again. Make a new box and try it again. Try running the script a few times from the macro menu on the ribbon if it works ok try assigning it to a button.
 
Upvote 0
I would suggest running the recorder again. Make a new box and try it again. Try running the script a few times from the macro menu on the ribbon if it works ok try assigning it to a button.

erm to confirm with you, when you said 'make a new box' you meant starting from button click and it generate a textbox to design the text box? and then stop the recording?
or i make a textbox beforehand and start recording from designing the box and stop after designing?
 
Upvote 0
I would suggest running the recorder again. Make a new box and try it again. Try running the script a few times from the macro menu on the ribbon if it works ok try assigning it to a button.

oh i realised if i assign the macro to my button . it only works if i have an existing textbox. then when i click the button it changes the colour of the textbox.
but what i want is when i click a button, it generates a textbox with colour.

i tried to start recording from the button click but strangely my button click doesnt works when i recording a macro.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top