• 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...

  • 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

dparteka

Member
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:
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
 
In addition you must reference Word Object Library. In the VBA editor click Tools > References and check Microsoft Word xx.x Object Library.
Code:
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
 
Back
Top