Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jul 2001
    Posts
    134
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word Macro (Word 2002)

    I'm having problems with an old macro that has been updated and/or transferred every time I've updated Office. I'm sending a copy of it with this note. I use it most often when creating labels in a table. When I select the first column with text in the first cell, it works just fine -- copies info in first cell to remaining cells in the column. However, when I select the second column and run the macro, the macro selects the text in the first cell of column one and the first cell of column two, then qives me an error message to debug. It does the same thing in column three, selecting the text in the first cell of columns one, two and three. Could someone please check the attached macro and try to determine why it only works properly in the first column? I've highlighted the area that it says needs to be "debugged". Thanks.
    Attached Files Attached Files

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Macro (Word 2002)

    This code (WordBasic and vermicelli! - whoopee!) takes the contents of the first cell in a column of selected cells (at least two cells) and copies the contents of the top cell to all the selected cells in the column, right? That works just fine for me no matter which column is selected. Despite your many updates, the code appears to work fine. Maybe merged cells are problematic. Nothing else comes to mind. What exactly is the error message?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  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 (Word 2002)

    If you single step through the code after starting with a selection of column two cells 1 and 2, you'll see the problem:

    WordBasic.WW7_EditGoTo Destination:="cell" 'expands the selection to the full first cell in the second column
    WordBasic.CharLeft 1, 1 'expands the selection to include the first cell in the first column, too (expands to the left)

    Change the second line to:

    Selection.MoveEnd unit:=wdCharacter, Count:=-1

  4. #4
    2 Star Lounger
    Join Date
    Jul 2001
    Posts
    134
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Macro (Word 2002)

    Wish I could say it worked for me. It's been driving me crazy. When I try to run it on the second column, it selects the text in the first cells of columns one and two, stops and comes up with a box that gives the options of "end" or "debug". I select "debug" and it highlights the text in the document I attached with my message.

  5. #5
    2 Star Lounger
    Join Date
    Jul 2001
    Posts
    134
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Macro (Word 2002)

    Thank you, thank you, thank you. I've recorded a lot of macros, but I've never really written one and I couldn't figure out the problem. But you did, and for that I am most appreciative.

Posting Permissions

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