Hi Paul,
Greetings from me!
Thank you.
I checked the ‘OUTPUT E’ folder. It’s empty. I changed the path but in vain. Still I’m getting error ‘method of data member not found’ on the same line. Please see the code below and suggest me what’s wrong.
Option Explicit
Sub Merge_To_Individual_Files1()
Application.ScreenUpdating = False
Dim StrFolder As String, StrName As String, MainDoc As Document, i As Long, j As Long, BlnEx As Boolean
Const StrNoChr As String = """*./\:?|"
Set MainDoc = ActiveDocument
With MainDoc
StrFolder = Replace(.Path, "c:\WORD\INPUT", "c:\WORD\OUTPUT E\")
For i = 1 To .MailMerge.DataSource.RecordCount
BlnEx = True
With .MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = i
.LastRecord = i
.ActiveRecord = i
If Trim(.DataFields("NAME_E")) = "" Then Exit For
StrName = .DataFields("NAME_E")
End With
If Trim(.DataFields("REMARK")) = "-" Then BlnEx = False 'Getting error method of data member not found
If BlnEx = True Then .Execute Pause:=False
End With
If BlnEx = True Then
For j = 1 To Len(StrNoChr)
StrTxt = Replace(StrName, Mid(StrNoChr, j, 1), "_")
Next
StrName = Trim(StrName)
With ActiveDocument
.SaveAs FileName:=StrFolder & StrName & ".docx", FileFormat:=wdFormatXMLDocument, AddToRecentFiles:=False
' and/or:
.SaveAs FileName:=StrFolder & StrName & ".pdf", FileFormat:=wdFormatPDF, AddToRecentFiles:=False
.Close SaveChanges:=False
End With
End If
Next i
End With
Application.ScreenUpdating = True
MsgBox "The task completed successfully."
End Sub
Thanking you,
Bookmarks