1. Welcome to Chandoo.org Forums. Short message for you

    Hi Guest,

    Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

    Yours,
    Chandoo
  2. Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  3. When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Delete Text Box in Excel > Word > Outlook

Discussion in 'VBA Macros' started by dparteka, May 18, 2017.

  1. dparteka

    dparteka Member

    Messages:
    133
    This may be a shot in the dark because it's an Outlook macro issue. Below are two sets of code that deletes text boxes, the first one works in MS Excel and the second in MS Word. The only difference between the two is the third line after "Active". I'm trying to duplicate this action in MS Outlook in a new-opened email but lack the knowledge of the proper code terminology... is there anyone out there that knows this... thank you, Dennis.
    Code (vb):
    Sub RemoveTextBox()
      Dim shp As Shape
      For Each shp In ActiveSheet.Shapes
      If shp.Type = msoTextBox Then shp.Delete
      Next shp
    End Sub

    Sub RemoveTextBox()
      Dim shp As Shape
      For Each shp In ActiveDocument.Shapes
      If shp.Type = msoTextBox Then shp.Delete
      Next shp
    End Sub
  2. dparteka

    dparteka Member

    Messages:
    133
    In addition you must reference Word Object Library. In the VBA editor click Tools > References and check Microsoft Word xx.x Object Library.
    Code (vb):
    Sub DeleteTextBox()
    Dim Inspector As Outlook.Inspector
    Dim wdDoc As Word.DocumentDim Shp As Word.Shape

    Set Inspector = Application.ActiveInspector()Set wdDoc = Inspector.WordEditor

    ForEach Shp In wdDoc.Shapes

    Debug.Print Shp.Type 'msoTextBox = 17 - Print on Immediate WindowIf Shp.Type = msoTextBox Then Shp.Delete

    Next

    EndSub
  3. SirJB7

    SirJB7 Excel R┼Źnin

    Messages:
    8,894

Share This Page