Log in

View Full Version : Solved: Merge Documents



jdegeorge
03-05-2013, 09:30 AM
Hi, MOS Master!

I have been searching high and low for a macro that would do what yours does.

I had to do some tweaking to get it to work for me...

I modified this SUB


Sub DoMerge(oDocument As Document, iRecord As Integer)
Dim sCPLongName As String
Dim sCombPath As String
With oDocument.MailMerge
With .DataSource
.FirstRecord = iRecord
.LastRecord = iRecord
.ActiveRecord = iRecord
sCPLongName = .DataFields("StatChangeNum").Value
End With
.Destination = wdSendToNewDocument
.Execute
End With

sCombPath = sMergePath & Application.PathSeparator & _
sCPLongName & ".docx"


(Deleted the unnecessary variables and changed to DOCX)

It worked just fine, then all of a sudden it doesn't any longer.

When the "select path" window opens, I select a path, but it closes without running. I open the DOTX merge document and link to the merge data file, but nothing happens. I believe those are the correct steps.

Could there be a problem with this bit? The variable shouldn't be NULL because I do select a folder.

sMergePath = MergeFolder
If sMergePath = vbNullString Then Exit Sub

I'm new to VBA and don't konw what could be wrong.

I know this post is almost 5 years old, but I would really appreciate a suggestion if you could.

Thanks!
Jim

Doug Robbins
03-05-2013, 11:40 PM
Download theMergeTools – 20121103 Add-in that I created from the following page of myWindows Live SkyDrive:
https://skydrive.live.com/?cid=5aedcb43615e886b#!/?cid=5AEDCB43615E886B!cid=5AEDCB43615E886B&id=5AEDCB43615E886B%21566 (https://skydrive.live.com/?cid=5aedcb43615e886b#!/?cid=5AEDCB43615E886B!cid=5AEDCB43615E886B&id=5AEDCB43615E886B%21566)

It contains a facility to Merge to Individual Documents

jdegeorge
03-06-2013, 06:45 AM
Doug

This is truly AMAZING!!!! As great as MOS's macro was, this utility appears to be extremely flexible. I have to set some time aside to learn all the features. Just amazing!

200+ individually-named documents created in practically no time! :thumb

Thank you, thank you, thank you! :bow:

Jim