Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

VBA Excel copy and paste the textbox to the speficied location

I would like to copy textbox to other location.

   Dim bonmb3a As Shape, bonmb3b As Shape
   Set bonmb3a = bow.Shapes.AddTextbox(msoTextOrientationHorizontal, 14, 333, 47, 21)
    With bonmb3a
        .Name = "Building Overview Box 3A"
        With .line
        .ForeColor.RGB = RGB(255, 192, 0)
        .Weight = 3
        End With
        With .TextFrame2
            .TextRange.Characters.Text = "3"
            .TextRange.ParagraphFormat.Alignment = msoAlignCenter
            With .TextRange.Characters.Font
                .Bold = msoTrue
                .size = 12
            End With
        End With
        .Copy
     End With
     Set bonmb3b = bonmb3a.Paste(550, 140, 47, 21)

but with the following code I can’t see pasted object. No error shown.

How could I copy the textbox to the specified location?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Just use Paste without parameters.
After pasting, the new textbox is the last shape on the sheet. Then you can modify the properties you need, eg position (top + left) or name or caption.

bow.Paste
Set bonmb3b = bow.Shapes(bow.Shapes.Count)
With bonmb3b
    .Left = 550
    .Top = 140
    .Name = "Building Overview Box 3B"
    .TextFrame2.TextRange.Characters.Text = "4"
End With
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading