Consulting

Results 1 to 7 of 7

Thread: copy tables from word without repeating header

  1. #1

    copy tables from word without repeating header

    Generate_Invoice.xlsmHi Paul, This is Mayur (continuing from stackoverflow) as there is no option to attach files. Hope you are same macropod [IMG]file:///C:/Users/User/AppData/Local/Temp/msohtmlclip1/01/clip_image001.gif[/IMG]
    Attached here with are the two invoice files... I am trying to copy the tables (with only header row: with keyword "Description").
    Following is the code that i am using. Also wanted to copy Invoice / sales order number with Date and paste in column E.
    The instr function is unable to find "Description". Hope you have all the details now. Sorry for the confusion and taking so much time of yours.
    Attached Files Attached Files

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Cross-posted (and answered before posting here) at: https://stackoverflow.com/questions/...peating-header
    Please read VBA Express' policy on Cross-Posting in Rule 3: http://www.vbaexpress.com/forum/faq...._new_faq_item3
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3

    copy tables from word without repeating header

    [QUOTE=macropod;402740]Cross-posted (and answered before posting here) at:
    Yes sir, since there was no option to upload files in stackoverflow

  4. #4
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,635
    Sub M_snb()
       with getobject("G:\OF\invoice.docx")
         For Each it In .Tables
            If InStr(it, "Description") Then c00 = c00 & vbCrLf & it
         Next
         .close 0
       end with
    
       CreateObject("scripting.filesystemobject").createtextfile("G:\OF\tbles.csv").write Replace(Join(Filter(Split(c00, vbCr & Chr(7) & vbCr & Chr(7)), "Description", 0), vbCrLf), vbCr & Chr(7), ",")
       Workbooks.Open "G:\OF\tbles.csv"
    End Sub

  5. #5
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    [QUOTE=mvakharia;402744]
    Quote Originally Posted by macropod View Post
    Yes sir, since there was no option to upload files in stackoverflow
    Quite irrelevant. When you joined this forum you agreed to abide by its rules. In any event, as per the line you quoted, the problem was already solved at StackOverflow before you posted here.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  6. #6

    copy tables from word without repeating header

    [QUOTE=macropod;402751]
    Quote Originally Posted by mvakharia View Post
    Quite irrelevant. When you joined this forum you agreed to abide by its rules. In any event, as per the line you quoted, the problem was already solved at StackOverflow before you posted here.
    Unfortunately still not working as desired and that's the main reason I wanted to share the file. With your revised Instr formula it does go inside the loop but deletes the first row which in case 1 is has two row header.
    Also unable to retrieve the Sales Order no. and Date from both the word files.
    Sorry for all the trouble and really appreciate all your help. God bless you!

  7. #7
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    [QUOTE=mvakharia;402752]
    Quote Originally Posted by macropod View Post
    ith your revised Instr formula it does go inside the loop but deletes the first row which in case 1 is has two row header.
    Also unable to retrieve the Sales Order no. and Date from both the word files.
    If you want help, kindly continue the discussion at StackOverflow. I have no intention of carrying on the discussion across two different forums. Thread closed.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

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