在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

解决方案 »

  1.   

    .Selection.Flags=wdSelOvertype或者wdSelReplace吧 我没有用过,试一下
      

  2.   

    .Documents.Open FileName:="1.doc", ConfirmConversions:=False, _
            ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
            PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
            WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
        .Options.Overtype = True
        
    试过了不行