+ Reply to Thread
Results 1 to 7 of 7

Macro not picking up all tables

  1. #1
    Registered User
    Join Date
    04-27-2010
    Location
    Louisville KY USA
    MS-Off Ver
    Excel 2003
    Posts
    25

    Question Macro not picking up all tables

    I realize this is an Excel forum but have a general VBA question I think. I'm trying to copy all tables in a Word document into a new document. This script is only pasting the first one, even though I can debug through it and see that the count of tables is 48 and I can watch i go from 1-48. It pastes the first one time, and then never pastes anything else again. I have a feeling it has to do with either selecting the table or using the correct activated document. I have only one document open at the time it runs (oDoc) and the only other one is the one that's created (oNewDoc). Any help appreciated.

    Thanks!

    Please Login or Register  to view this content.
    Last edited by mateoc15; 06-09-2011 at 10:09 AM.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Macro not picking up all tables

    Can you post a document with a few tables in it, I don't feel like guessing..
    Also, note that the site has a Word forum, so the question is ok.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    04-27-2010
    Location
    Louisville KY USA
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: Macro not picking up all tables

    Unfortunately the file is somewhat proprietary and confidential. I can tell in debugging that the macro IS picking up that the document has 48 tables. Can you tell me if you think I'm activating and deactivating documents correctly, and if my copy/paste logic looks right? This is my first crack at copy/paste across documents.

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Macro not picking up all tables

    Did I miss the bit in the code where the copying occurs?
    Remember what the dormouse said
    Feed your head

  5. #5
    Registered User
    Join Date
    04-27-2010
    Location
    Louisville KY USA
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: Macro not picking up all tables

    Quote Originally Posted by romperstomper View Post
    Did I miss the bit in the code where the copying occurs?
    Unfortunately I can't edit a post.
    Please Login or Register  to view this content.
    is actually
    Please Login or Register  to view this content.
    The problem remains.

    EDIT: (haha) I did just change it in the original post to reflect the change noted in this post.

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Macro not picking up all tables

    Oh OK. I've moved this to the Word programming zone in the hope that someone who knows Word VBA will happen by.

  7. #7
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Macro not picking up all tables

    When I ran your code on a test document, it seemed to be pasting each new table on top of the previously pasted one. Therefore, try this one:
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1