+ Reply to Thread
Results 1 to 2 of 2

Export data to the rigth word table

Hybrid View

Duart Export data to the rigth word... 08-22-2012, 10:59 PM
Tinbendr Re: Export data to the rigth... 08-23-2012, 12:24 PM
  1. #1
    Registered User
    Join Date
    07-31-2012
    Location
    Lisbon
    MS-Off Ver
    Excel 2010
    Posts
    1

    Export data to the rigth word table

    I want to put data into tables in a word document from multiple sheets.
    The word document can be changed by the user including introducing new tables.

    When I enter a new table in the word document data is exported to the wrong place.

    I am using:
    Set xclRange = xclSheet.Range("A1").CurrentRegion
    For lnIncre = 1 To xclRange.Rows.Count
            For clIncre = 1 To xclRange.Columns.Count
                    wrdDoc.Tables(3).Cell(lnIncre, clIncre).Range = xclRange(lnIncre, clIncre)
            Next clIncre
        Next lnIncre
    Is it possible to assign a name to the table instead of using its position in the word document?

    Tables(My_Table_Name) instead of Tables(3) ?

    I thought using bookmarks but prefer avoid that solution.

    -----

    I am new user of VBA and excuse my English.
    I attached the files to clarify the question
    Thank's in advance.

    xcll_SPECIM.xlsm
    wrd_SPECIM.docx
    wrd_SPECIM_ALT.docx

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Export data to the rigth word table

    Quote Originally Posted by Duart View Post
    Is it possible to assign a name to the table instead of using its position in the word document?

    Tables(My_Table_Name) instead of Tables(3) ?
    One feature sorely missed in Word.

    I thought using bookmarks but prefer avoid that solution.
    You can encapsulate a table IN a bookmark.

    wrdDoc.Bookmarks(MyBookMark).Tables(1).Cell(lnIncre, clIncre).Range = xclRange(lnIncre, clIncre)

    But to me, if you have to add the bookmark, then you already know the table number. (Unless you have lots of tables.)

    If the tables have any recognizable text in them, you might be able to find it this way.

    You could put the cursor in the table in question, then use Selection.Information(wdWithInTable)
    to get a handle on it.

    Your sample files are really vague so I can not offer any other suggestions.
    David
    (*) Reputation points appreciated.

+ 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