Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Frame Problems (VBA/Word/2000 SP3 & 2003)

    The attached file contains a table which is selected by the following snippet of code (.Select), yet the following command (.Delete), fails.

    I don't know the source of the offending text, as our documents typically are created through a great deal of cutting and pasting from a myriad of sources.

    Any insight into what is going on will be greatly appreciated.

    <pre>Selection.WholeStory
    For i = 1 To Selection.Frames.Count
    Selection.WholeStory
    With Selection.Frames(1)
    .Select
    .Delete
    End With
    Next i</pre>



    Thanks in advance
    Regards
    Don

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Frame Problems (VBA/Word/2000 SP3 & 2003)

    What is it that you actually want to achieve? The table is selected as a Frame because it is floating (has Text Wrapping turned on in Tables > Table Properties) - perhaps that is what you are trying to solve.

    This type of code can work a lot faster if you do one of the following
    'delete all tables from doc
    Dim aTable As Table
    For Each aTable In ActiveDocument.Tables
    aTable.Delete
    Next aTable

    'Delete all Frames
    Dim aFrame As Frame
    For Each aFrame In ActiveDocument.Frames
    aFrame.Delete
    Next aFrame
    End Sub

    'Delete all frames and floating tables
    Dim aFrame As Frame
    For Each aFrame In ActiveDocument.Frames
    If aFrame.Range.Tables.Count = 1 Then
    aFrame.Range.Tables(1).Delete
    Else
    aFrame.Delete
    End If
    Next aFrame
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Frame Problems (VBA/Word/2000 SP3 & 2003)

    I think you're bitten by the strange new behavior of tables, which seem to be floating and inline at the same time. Word reports the table to be in a frame, but it's not a "normal" Word frame.

  4. #4
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Frame Problems (VBA/Word/2000 SP3 & 2003)

    Andrew and Hans

    Thank you both. It's much clearer now. I need to remove the frames that have been converted from text boxes.
    <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>
    This is such a great collection of knowledgeable people. Thanks again.
    Regards
    Don

Posting Permissions

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