word vba mail merge

  • Dear Guys


    Good Morning


    i have the following word vba codes which are running correctly


    Sub Macro2()
    '
    ' Macro2 Macro
    '
    Documents.Open FileName:="testing.docx", AddToRecentFiles:=False
    strSourceDoc = ActiveDocument.Path & "" & "fixedcharge.xls"
    ActiveDocument.MailMerge.OpenDataSource Name:= _
    strSourceDoc, _
    Format:=wdOpenFormatAuto, Connection:= _
    "Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=" & strSourceDoc & ";Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Je" _
    , SQLStatement:="SELECT * FROM `'Sheet$1'`", SQLStatement1:="", SubType _
    :=wdMergeSubTypeAccess
    With ActiveDocument.MailMerge
    .Destination = wdSendToNewDocument
    .SuppressBlankLines = True
    With .DataSource
    .FirstRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord
    .LastRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord
    End With
    .Execute Pause:=False
    End With
    'ActiveDocument.SaveAs2 FileName:="SOW1.docx", FileFormat:= _
    ' wdFormatXMLDocument, Password:="", AddToRecentFiles _
    ':=True, CompatibilityMode:=14
    End Sub [h=1][SIZE=12px]my problem is that in my excel sheet there are more than 1 records. When word document is saved to SOW1.docx, only one record is saved the others not saved.[/SIZE][/h] your help will be highly appreciated


    thanks/regards


    rakesh

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!