Doc. Assembly - selector

Melaco

New Member
Joined
Aug 22, 2017
Messages
2
Dear all,

First of all I'm glad to be joining the Forum.

Said that, I'll expose my issue...

I've currently an excel file, in which I've all the document links from a modular catalogue, in different columns (depending on each one's language).

I need to create a macro that (once having performed a specific selection, by ticking or placing an "X" somewhere, it opens just those filtered *.doc documents (which links are on the same file) and merge them in one single *.doc document.

Do you think that is possible? If so, could you please help me (I'm totally new at the macro environment...)

Many thanks in advance,

Manel
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Yes, it's possible, but you'll need to provide more details about how the destination document is to be identified and, likewise, specific details of each of the source documents is to be identified (e.g. how to recognise which ones have been chosen and how their location on disc is to be obtained).
 
Upvote 0
Thanks for your answer Paul,

I attach a screenshot hereafter, as a sample, and can attach as well the *.xls file if it helps...

As you see I've the Nº / Description and afterwards I want that depending on which "X" I place on the columns E and G, runing the macro it merges the *.doc files located on the links in colums J (for spanish) and L (for english) in one unique document.

[TABLE="class: grid, width: 500"]
[TR]
[TD]#
[/TD]
[TD]ESP DESCR.
[/TD]
[TD]ENG.DESCR
[/TD]
[TD]place "X" if ESP
[/TD]
[TD]place "X" if ENG
[/TD]
[TD]ESP Link
[/TD]
[TD]ENG Link
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1

[/TD]
[TD]XX
[/TD]
[TD]AA
[/TD]
[TD][/TD]
[TD][/TD]
[TD]Links to my network original files location...
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]XXY
[/TD]
[TD]AAB
[/TD]
[TD]X
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]XXYY
[/TD]
[TD]AABB
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5111
[/TD]
[TD]XXYYZZ
[/TD]
[TD]AABBCC
[/TD]
[TD]X
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[/TABLE]
Concerning the destination document, I don't care that much, the aim is to be able to simplify the act of merging the doc. among the doc. library, each time I'll need to create a new specific combination... So the destination document identification and its storage is totally secondary.

Thanks again for your support!

Looking forward to hearing from you,
Manel
 
Last edited by a moderator:
Upvote 0
Try:
Code:
Sub Demo()
' Note: This code requires a reference to the Microsoft Word object library.
' See in the VBE under Tools|References.
Dim wdApp As New Word.Application, wdDocTgt As Word.Document, wdDocSrc As Word.Document
Dim r As Long
Set wdDocTgt = wdApp.Documents.Add
With ActiveSheet
  For r = 2 To .UsedRange.Cells.SpecialCells(xlCellTypeLastCell).Row
    If UCase(Trim(.Range("E" & i).Value)) = "X" Then
      Set wdDocSrc = wdApp.Documents.Open(Filename:=.Range("J" & i).Value, _
        ReadOnly:=True, AddToRecentfiles:=False, Visible:=False)
      With wdDocTgt
        .Range.InsertAfter vbCr
        .Range.Characters.Last.FormattedText = wdDocSrc.Range.FormattedText
      End With
      wdDocSrc.Close False
    End If
    If UCase(Trim(.Range("G" & i).Value)) = "X" Then
      Set wdDocSrc = wdApp.Documents.Open(Filename:=.Range("L" & i).Value, _
        ReadOnly:=True, AddToRecentfiles:=False, Visible:=False)
      With wdDocTgt
        .Range.InsertAfter vbCr
        .Range.Characters.Last.FormattedText = wdDocSrc.Range.FormattedText
      End With
      wdDocSrc.Close False
    End If
  Next
  wdDocTgt.Range.Characters.First.Delete
End With
Set wdDocSrc = Nothing: Set wdDocTgt = Nothing: Set wdApp = Nothing
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top