Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Finding and Formatting Bordered/Nonborderd Tables

    I am using Word 97 SR2.
    I am trying to create a macro that will find bordered tables and nonbordered tables and perform certain steps to each. I have attached a txt file with my first attempt, which is failing.

    I am not a VBA programmer, but have taken the text of this macro from macros give by Gary Frieder, macros I am already using, and macros I have seen in other postings.

    I have put comments throughout the text of the macro to show what I am trying to acccomplish.

    Thanks for any help you can give!!
    Troy
    Attached Files Attached Files

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Finding and Formatting Bordered/Nonborderd Tables

    Hi Troy,

    Here are a few corrections to the code, that should get you further along:

    This causes a compile error:
    ElseIf aPara.Range.ListFormat.ListType = None Then

    Replace it with:
    ElseIf aPara.Range.ListFormat.ListType = wdListNoNumbering Then


    This causes a compile error:
    ElseIf aTable.Borders(wdBorderLeft).LineStyleNone

    Replace it with:
    ElseIf aTable.Borders(wdBorderLeft).LineStyle = wdLineStyleNone

    There are two errors in this line:
    For Each aPara In ActiveDocument.Tables 'For every paragraph in the table....

    (1) "aPara" is already in use in the outer For Each.. loop, so you need to define a different variable here (such as "tPara" - put a "Dim tPara As Paragraph" declaration at the top).

    (2) What you really want to do here is loop through every paragraph in the current table.

    The following should take care of both issues:
    For Each tPara In Selection.Tables(1).Range.Paragraphs

    There may be another bug or two lurking in there, but this should take you further anyway <g>

    Gary

  3. #3
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding and Formatting Bordered/Nonborderd Tables

    Thanks for the help!! What you gave me, plus a little tweaking of my own, allowed me to search for and format the tables as I wanted to. <img src=/S/yep.gif border=0 alt=yep width=15 height=15>

    Just wanted to let you know I have received high praise from my manager (and even a couple of movie tickets) for the work I am doing on these macros. I gave you credit by name for your part in this. I guess I say all that to say you are doing a super job, and I really appreciate it. The series of macros I have developed with your help will save us literally hundreds, if not thousands, of hours of work. <img src=/S/joy.gif border=0 alt=joy width=23 height=23>

    Thanks again!!
    Troy <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Finding and Formatting Bordered/Nonborderd Tables

    Glad to hear that you had such useful results - your comments made my day!

    Now, which movie are we going to go see? <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>

Posting Permissions

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