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

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
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.

#
ESP DESCR.
ENG.DESCR
place "X" if ESP
place "X" if ENG
ESP Link
ENG Link
1

XX
AA
Links to my network original files location...
2
XXY
AAB
X
3
XXYY
AABB
5111
XXYYZZ
AABBCC
X
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,221,418
Messages
6,159,791
Members
451,589
Latest member
Harold14

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