Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Mar 2007
    Location
    Montreal, Quebec
    Posts
    125
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Selecting and deleting text boxes

    When we scan documents we get a bunch of text boxes floating around (page numbers are a good example). I wrote a macro that selects the textboxes one by one and lets me decide if I want to delete it or not. The only problem is that it does not show me the textbox. The first textbox seems to always be selected in other words it does not "scroll down" to the next textbox. It stays on the same page. Here is my code. Could someone let me know what I am missing. Tks

    For Each box In ActiveDocument.Shapes
    With box.Select
    response = MsgBox("Voulez-vous supprimer la boîte de texte sélectionnée ?", _
    vbYesNo + vbQuestion + vbDefaultButton2, "Suppression des boîtes de texte")
    If response = vbYes Then
    Selection.ShapeRange.Delete
    End If
    End With
    Next box
    Johanne Champagne
    Montreal (Quebec) CANADA

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    You could try the ScrollIntoView method:

    Code:
    Dim box As Word.Shape
    For Each box In ActiveDocument.Shapes
        box.Select
        ActiveDocument.Windows(1).ScrollIntoView Selection.Range, True
        If MsgBox("Voulez-vous supprimer la boîte de texte sélectionnée ?", _
            vbYesNo + vbQuestion + vbDefaultButton2, _
            "Suppression des boîtes de texte") = vbYes Then
            Selection.ShapeRange.Delete
        End If
    Next box
    Last edited by jscher2000; 2011-04-14 at 20:27. Reason: Bolded the most relevant line.

  3. #3
    2 Star Lounger
    Join Date
    Mar 2007
    Location
    Montreal, Quebec
    Posts
    125
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Woks perfectly. Tks alot! I knew I was close but I only do code once or twice a year.
    Tks again.
    Johanne Champagne
    Montreal (Quebec) CANADA

Posting Permissions

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