• Finding and Formatting Bordered/Nonborderd Tables

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Finding and Formatting Bordered/Nonborderd Tables

    Author
    Topic
    #355389

    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

    Viewing 0 reply threads
    Author
    Replies
    • #524033

      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

      Gary

      • #524272

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

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

        Thanks again!!
        Troy grin

        • #524388

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

          Now, which movie are we going to go see? laugh

    Viewing 0 reply threads
    Reply To: Finding and Formatting Bordered/Nonborderd Tables

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: