Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Mar 2002
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Selecting table in a macro (Word 2000)

    Creating Macro. Want to record using CtrlA to select all - all being a table with 58 rows which spans 2 pages. I put other text in doc in text box to keep from being captured by CtrlA. Use Ctrl+A, both tables highlight, then I click on Table, then Sort and even tho I check Header, my sort selections are only Paragraph and Field 1. If I do not use CtrlA, click on first table, click on Tools, Record Macro, assign keyboard keys, apply only to current temp - not global nor normal.dot, then I can specify my column with its' heading, 1st sort and 2nd sort by field. So I assign Ctrl+Q. Macro works great! Put cursor on 2nd page in 2nd table, click Tools, Record Macro, apply to current template only, no header (header only resides on 1st table), then Table, Sort I get a choice of Column #'s 1or 2 which is exactly what I want to sort by. Have assigned Alt+Ctrl+Q for this one. Only one works. No matter how I try it using this blueprint only one (and it doesn't appear to matter which one) of the macros work. Needless to say - I need help.

    <img src=/S/bummer.gif border=0 alt=bummer width=15 height=15>

  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

    Re: Selecting table in a macro (Word 2000)

    The first thing is to get that Enter key fixed so you can separate your thoughts into paragraphs! <img src=/S/wink.gif border=0 alt=wink width=15 height=15>

    If you select two tables with paragraphs in between, Word treats the entire selection as paragraphs. It knows no better.

    In a macro, there are several efficient ways to select a table (one at a time). For example:
    1. <LI>If your insertion point (cursor) is anywhere in the table you want to select, then use Selection.Tables(1).Select to select the first table. This also will work if you have the whole document selected, the first table will be selected.

      <LI>If your insertion point is in an arbitrary or unknown location/state, you can use ActiveDocument.Tables(1).Select to select the first table.
    In either case, increment the index to select the second, third, etc. tables. If you use a number that doesn't correspond to a table, like 12, you will of course get an error.

    But... you do not even need to select the table to sort it. Try this:

    ActiveDocument.Tables(1).Sort (followed by the relevant parameters)

    Hope this helps. By the way, why did you split the table? Maybe we can fix that, too. There are several ways to make a table break nicely across a page boundary that will simplify keeping it in the order you want.

  3. #3
    Star Lounger
    Join Date
    Mar 2002
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selecting table in a macro (Word 2000)

    Enter key fixed! Sometimes I get crazed about saving space for no earthly reason. <img src=/S/blush.gif border=0 alt=blush width=15 height=15>

    I hadn't intentionally split table but.....what I apparently decided to do was double the size of it and instead of continuing it, I copied and pasted page one to page 2. Have fixed that. Now Table, Select Table works for both pages. Thanks!

    Recorded macro and accidentially applied it to Normal.dot. Got message "The macros in this project are disabled. Please refer...." I assume this is what one gets when one is in a different template? Never seen it before.

    Then I re-recorded macro correcting myself on that and when I run I get "Run-time error "594l": The requested member of the collection does not exist."



    <img src=/S/crazy.gif border=0 alt=crazy width=15 height=15>

  4. #4
    Star Lounger
    Join Date
    Mar 2002
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selecting table in a macro (Word 2000)

    STOP! Waste no energy on my last "error message" post.

    I had not deleted the macro I messed up before redoing it with the same keyboard assignments. I don't know why WORD isn't smart enough to know which one I wanted to dump. <img src=/S/bash.gif border=0 alt=bash width=35 height=39>

    Mission accomplished! Your input saved the day. THANKS! <img src=/S/bravo.gif border=0 alt=bravo width=16 height=30>

Posting Permissions

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