Copying and Pasting in a Rectangle/Text Box

Ste_Moore01

Active Member
Joined
Jul 13, 2005
Messages
467
Hi,

I have a text box/rectangle (named Rextangle 17) that I want to paste some text in using a macro.

Is there a way of doing this?

Thanks! :biggrin:
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
record of macro of the steps and edit the macro to suit you.

or use this
Public Sub test()
Dim textbox1 As TextBox
ActiveSheet.textbox1.Text = "my name is venkat"

End Sub
 
Upvote 0
I don't know why but your code didn't seem to work for me.

Thanks for trying though.

When I tried recording a macro on my work computer it didn't work when I either changed a formula or typed thigns in a text box.

I've tried it on my home computer though and it works fine.

I'm going to copy the code that it recorded and try it on my work computer.

I'll keep you posted as to whether it works or not.

Thanks again Venkat!

Also, this is my 200th post here at Mr Excel! Wooo! :LOL: :p
 
Upvote 0
have you opened a text box and then run the macro?
If you have not you have to add another code statement(s) for opening the text box . I shall look into it and write to you

ilooked into it if you have not already opened a textbox use this sub
Public Sub textbox()
Dim mydocument
Set mydocument = Worksheets(1)
mydocument.Shapes.AddTextbox(msoTextOrientationHorizontal, _
100, 100, 200, 50) _
.TextFrame.Characters.Text = "my name is venkat"
End Sub
you can get this in the help <add textbox example>
 
Upvote 0
I had already added a textbox and I wasn't editing the text when using the macro.

I wanted to make it so that I entered some data in a cell, run a macro and the data would be copied to the text box.

I managed to record a macro on my home computer to do it and I've used the same code on my work computer and it works.

The code I used (which I've modified so it copies the text and pastes it in the box) is
Code:
Dim text1 As String
text1 = Sheets("DETAILS ENTRY").[D2]
    Sheets("PRICEPACK").Shapes("Text Box 30").Select
    Selection.Characters.Text = text1
    With Selection.Font
        .name = "Arial"
        .Size = 30
    End With
    Selection.Font.Bold = True
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
    End With
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,409
Members
448,959
Latest member
camelliaCase

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