Results 1 to 9 of 9
  1. #1
    Star Lounger
    Join Date
    Mar 2001
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word Macro (2000)

    I have a document with multiple tables (separated). What I would like to do is create a macro that selects a certain table and then pulls out only the rows that have text in the second column and puts these rows at the bottom of the document as a new page. The table has four columns. First column has a few lines of text describing an action that has to be taken (this is a "minutes" document). The second column will have a name of the person that is responsible for the action (Last name, first name). The third column would have a due date. So really what I want is to pull out just the action items, which would be the rows with a person's name in the second column, and list them on a separate page at the bottom of the document. Also would like it to be sorted by ascending alpha order by person's name. I have done macros using tools - macros and recording the macro while performing certain steps. I believe I would have to use VB code and I am not real familiar with that. I hope this makes sense.

    Just another thought. Would it make more sense to create fields using table of contents fields? This way if I update the body of the document it would also update the summary page at the end of the document. Thank you for any help you can give.

    Dorothy

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Macro (2000)

    Hi Dorothy:
    I'm not a VBA expert, so I can't help with the macro. However, I can think of another way of doing this, depending upon your actual needs. If you have a Word table in a document as a data source, you can create a second document as a mailmerge.

    Your data source would have your 4 columns, each with a name at the top of the column. So your 4 columns would be:
    <table border=1><td align=center valign=top>Action</td><td align=center valign=top>Person</td><td align=center valign=top>Date</td><td align=center valign=top>??</td></table>
    Then you would set up a 4 column single row table & use mail merge (with Step 1 = category). The syntax for your fields would be:

    {IF {mergefield Date} <> "" "Here you put in what you want to appear" ""}
    where the curly brackets are inserted using Ctrl+F9; you cannot type them. Note that in place of Here you put in etc., you would place whatever mergefield you needed (i.e. the {mergefield Action} in the first column etc. I don't know if this will suit your needs, as it creates a second document.
    Cheers,

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Word Macro (2000)

    My first instinct would be to copy the entire table, go to the end, paste, sort by person, then secondary criterion, then use Table>Split to make individual tables for each person. I guess if I had to do this every day I'd write a macro, but for a weekly or monthly task, it's not worth it. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    Regarding a table of contents, I don't quite see how it fits into this project. Or should I say, it wouldn't seem to save you any time, although a TOC is always nice to have in a lenthy document.

  4. #4
    Star Lounger
    Join Date
    Mar 2001
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Macro (2000)

    Hi. Yes, that would be a way to do it, but the minutes have a lot of rows in between, rows that are not needed in the summary page. So once the table was pasted at the end of the document the person would have to go through and delete all the information that was not needed. This is what they wanted to avoid. I could create a macro that would select the entire table and then paste it at the end of the document and sort ascending by the person responsible for the action but I would like to include in this macro to just pull the rows that have a person's name in the second column. Again, I believe that would take some VB code but not sure what that is. Thank you for you reply. If you have any other suggestions on how to do this they would be greatly appreciate.

  5. #5
    Star Lounger
    Join Date
    Mar 2001
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Macro (2000)

    Hi Phil,

    Thank you for your reply. That was certainly one suggestion to create a merge document. Can you take it a bit further for me so that I am sure that I understand? In the merge document can I indicate to only pull the rows that have a person listed as responsible for an action? Again, that would be if the second column of a row has any name in it. There are multiple rows in the minutes and lots in between the action items that are not needed. Thank you again.

    Dorothy

  6. #6
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Macro (2000)

    Hi Dorothy:
    The syntax
    {IF {mergefield Person} <> "" "Here you put in what you want to appear" ""}
    says that if the Person field is blank in that row, put in nothing; otherwise, put in whatever fields that you want.

    What goes in the area "Here you put....appear" depends upon what fields you want. For example, if you wanted only the Person, Action, & Date whenever there is a person's name in the person field, it would look like this:

    Put this in the first cell of the 1 row table:
    {IF {Mergefield Person} <> "" "{Mergefield Person}" ""}

    Put this in the second cell of the 1 row table:
    {IF {Mergefield Person} <> "" "{Mergefield Action}" ""}

    Put this in the third cell:
    {IF {Mergefield Person} <> "" "{Mergefield Date}" ""}

    For more information on how to fill in IF fields & how they work, see <post#=273185>post 273185</post#>. If you have a problems, post back with a specific question & I'll try to help.
    Cheers,

  7. #7
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Macro (2000)

    Hi Dorothy:
    Jefferson's not online right now, so let me answer this. If you follow his suggestion & sort by the "person" column, all your extraneous rows will be the top rows of the table (since the blank Person cells will be at the top). You could then delete all those rows in one fell swoop, leaving only the rows with a named person.
    Cheers,

  8. #8
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Word Macro (2000)

    Adding on to Phil's last comment above, if you did record a macro of copying the table, pasting at the end, and sorting by the second column, you then could wrote a look to look at the second cell of each row. If that cell was blank, delete the row and continue. If the cell is not blank, check the contents and, if the contents are unchanged from the previous row, just continue, but if they are different, split the table so that it is the first row of a new table.

    This is a bit complicated to program because you are altering the number of rows and tables at the same time. Unfortunately I don't have time to work on it right now, but does this help at all?

  9. #9
    Star Lounger
    Join Date
    Jun 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Macro (2000)

    Out of curiosity( I rarely work with tables), I've knocked together a quick and inelegant macro/VBA just to see how it would work.
    Unfortunately recording a macro for anything but a simple sequence of actions is usually the start of a problem not the solution to it.

    The attached document has the macro in the ThisDocument object which is fired off by the command button .

    If you want to follow this line then please re-post in the VBA area.
    Hope this is helpful,
    Attached Files Attached Files

Posting Permissions

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