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:
 

Some videos you may like

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

venkat1926

Well-known Member
Joined
Aug 21, 2005
Messages
4,824
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
 

Ste_Moore01

Active Member
Joined
Jul 13, 2005
Messages
467
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
 

venkat1926

Well-known Member
Joined
Aug 21, 2005
Messages
4,824
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>
 

Ste_Moore01

Active Member
Joined
Jul 13, 2005
Messages
467
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
 

Watch MrExcel Video

Forum statistics

Threads
1,118,231
Messages
5,571,028
Members
412,355
Latest member
BasicExelHelp
Top