Z
ZZK
I need help debugging the following code. I'm a novice, so please don't
laugh at me.
When I run it, it only merges the very first record in the
data source. Basically, all I want it to do is select a record from the data
source, based on an account number and merge that particular record. What's
missing? Any help would be greatly appreciated!
Sub SRFulfill()
'
' SRFulfill Macro
'
Dim strEnterAcct As String
Dim dsMain As MailMergeDataSource
Dim intRecordNum As Integer
strEnterAcct = InputBox("Please Enter an Account Number", "Enter Account")
Set dsMain = ActiveDocument.MailMerge.DataSource
If dsMain.FindRecord(FindText:=strEnterAcct, Field:="ACCOUNT") = True Then
intRecordNum = dsMain.ActiveRecord
End If
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = intRecordNum
.LastRecord = intRecordNum
End With
.Execute Pause:=False
End With
End Sub
laugh at me.
data source. Basically, all I want it to do is select a record from the data
source, based on an account number and merge that particular record. What's
missing? Any help would be greatly appreciated!
Sub SRFulfill()
'
' SRFulfill Macro
'
Dim strEnterAcct As String
Dim dsMain As MailMergeDataSource
Dim intRecordNum As Integer
strEnterAcct = InputBox("Please Enter an Account Number", "Enter Account")
Set dsMain = ActiveDocument.MailMerge.DataSource
If dsMain.FindRecord(FindText:=strEnterAcct, Field:="ACCOUNT") = True Then
intRecordNum = dsMain.ActiveRecord
End If
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = intRecordNum
.LastRecord = intRecordNum
End With
.Execute Pause:=False
End With
End Sub