Consulting

Results 1 to 2 of 2

Thread: Add shape only if shape doesn't already exist

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Add shape only if shape doesn't already exist

    I'm trying to add a text box shape. I have the code written to add the text box where I want it and how I want it formatted.

    Dim Message As Integer
    Dim messagebx As Shape
    Message = MsgBox("Would you like to include a message to the client?", vbYesNo + vbQuestion, "Message")
    If Message = vbYes Then
            Range("C12:L12").Merge
            rows("12:22").insert
                Set messagebx = Shapes.AddTextbox(msoTextOrientationHorizontal, 22, 165, 473, 185)
                messagebx.TextFrame.Characters.Text = "[Insert Message]"
                messagebx.TextFrame.Characters.Font.Size = 9
                messagebx.TextFrame.Characters.Font.Name = "Arial"
                messagebx.Line.Visible = msoFalse
            Else
            'do nothing
            End If


    After this and a bunch of other code is performed, my sheet can be updated and the code re-ran. But if I re-run the code, this text box is replaced with a new blank box. I'd like it to just stay using an error handling statement or something. I'm just not familiar with error handling.
    Last edited by Aussiebear; 12-31-2016 at 03:40 PM. Reason: Added code tags

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •