|
Sub 宏3()
'
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:= _
"C:\Users\xz\Desktop\新建文件夹\统计表.xls", ConfirmConversions:=False, ReadOnly _
:=False, LinkToSource:=True, AddToRecentFiles:=False, PasswordDocument:= _
"", PasswordTemplate:="", WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=wdOpenFormatAuto, _
Connection:= _
"Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=C:\Users\xz\Desktop\新建文件夹\统计表.xls;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Engine Type=35;Jet OLEDB:Database Locking Mode=" _
, SQLStatement:="SELECT * FROM `统计表$`", SQLStatement1:="", SubType:= _
wdMergeSubTypeAccess
Selection.MoveDown Unit:=wdLine, Count:=5
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=3
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=4
Selection.MoveUp Unit:=wdLine, Count:=7
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:="编号"
Selection.MoveDown Unit:=wdLine, Count:=5
Selection.MoveLeft Unit:=wdCharacter, Count:=2
Selection.MoveDown Unit:=wdLine, Count:=5
Selection.MoveLeft Unit:=wdCharacter, Count:=3
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:="姓___名"
Selection.MoveDown Unit:=wdLine, Count:=3
Selection.MoveLeft Unit:=wdCharacter, Count:=4
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:="日期"
Selection.MoveRight Unit:=wdCharacter, Count:=7
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:="金额"
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=20
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:="大写"
Selection.MoveRight Unit:=wdCharacter, Count:=9
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:="发放方式"
Selection.HomeKey Unit:=wdLine
Selection.MoveRight Unit:=wdCharacter, Count:=4
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=12
Selection.MoveLeft Unit:=wdCharacter, Count:=2
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=7
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=20
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdLine, Count:=2
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeBackspace
Selection.MoveUp Unit:=wdLine, Count:=8
Selection.MoveRight Unit:=wdCharacter, Count:=4
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
End Sub
|
|