Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Sep 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Embeded Word Objects in Excel (XP & 2000 Pro)

    <P ID="edit" class=small>(Edited by jscher2000 on 16-Sep-04 10:06. Line endings removed to better fit Lounge display.)</P>I have an Excel template with 10 embedded Word documents. I receive completed templates from 12 different business units. Currently, I cut and past the text from Excel to a Word table - but am getting a little fed up with the 120 cut & paste operations I have do to create my consolidated report.

    Can anybody help me to write the code to link the data from the templates to a Word table? I am fairly adept with Excel VBA but have no exposure to Word VBA.

    Help please.

    QB

  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: Embeded Word Objects in Excel (XP & 2000 Pro)

    Are the source documents 120 Word documents, delivered inside 12 Excel workbooks? That is a bit messy.

    Word VBA can automate your copy and paste step once you've opened each Word document. For example, if you always copy the first table in the source document to the end of the consolidated document, this kind of code might do the trick:

    Dim docDest as Word.Document, docSource as Word.Document, rngToPaste as Range
    ' Create destination document here
    ' ...
    ' Start some kind of loop here
    ' ...
    ' Transfer first table in source document to end of destination document
    docSource.Tables(1).Range.Copy
    Set rngToPaste = docDest.Content
    With rngToPaste
    .InsertAfter vbCrLf & "[" & docSource.Name & "]" & vbCrLf
    .Collapse Direction:=wdCollapseEnd
    .Paste
    End With
    If Not (rngToPaste Is Nothing) Then Set rngToPaste = Nothing
    ' Dispose of source document and continue looping
    ' ...

    What I'm not sure how to do is to automate the launching of each Word document from the Excel workbook.

Posting Permissions

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