在word里将MyWord.Options.Overtype=true,插入数据后却是插入不覆盖原来的数据
代码如下:
With MyWord
.Documents.Open FileName:="1.doc", ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
.Options.Overtype = True
.Selection.HomeKey Unit:=wdLine
.Selection.MoveRight Unit:=wdCharacter, Count:=34
.Selection.TypeText Text:="1212121212"
.Selection.HomeKey Unit:=wdLine
.Selection.MoveRight Unit:=wdCharacter, Count:=81
.Selection.TypeText Text:=Str(Year(Date))
.Selection.HomeKey Unit:=wdLine
.Selection.MoveRight Unit:=wdCharacter, Count:=89
.Selection.TypeText Text:=Str(Month(Date))
.Selection.HomeKey Unit:=wdLine
.Selection.MoveRight Unit:=wdCharacter, Count:=94
.Selection.TypeText Text:=Str(Day(Date))
.Documents.Close
代码如下:
With MyWord
.Documents.Open FileName:="1.doc", ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
.Options.Overtype = True
.Selection.HomeKey Unit:=wdLine
.Selection.MoveRight Unit:=wdCharacter, Count:=34
.Selection.TypeText Text:="1212121212"
.Selection.HomeKey Unit:=wdLine
.Selection.MoveRight Unit:=wdCharacter, Count:=81
.Selection.TypeText Text:=Str(Year(Date))
.Selection.HomeKey Unit:=wdLine
.Selection.MoveRight Unit:=wdCharacter, Count:=89
.Selection.TypeText Text:=Str(Month(Date))
.Selection.HomeKey Unit:=wdLine
.Selection.MoveRight Unit:=wdCharacter, Count:=94
.Selection.TypeText Text:=Str(Day(Date))
.Documents.Close
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
.Options.Overtype = True
试过了不行