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
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