1. 当前位置: 首页 >> CAD插件 >>

      如何实现批量替换多个word文件中的某一页

      0
      新建的页要写在("c:新建的页.doc")中。

      Sub s1() '批量换第七页
      On Error Resume Next
      Application.ScreenUpdating = False
      Dim MyPath As String, i As Integer, myDoc As Word.Document, mydoc2 As Word.Document
        With Application.FileDialog(msoFileDialogFolderPicker)
          .Title = "选择目标文件夹"
          If .Show = -1 Then
            MyPath = .SelectedItems(1)
          Else
            Exit Sub
          End If
        End With
        With Application.FileSearch
          .LookIn = MyPath
          .FileType = msoFileTypeWordDocuments
          If .Execute > 0 Then
         For i = 1 To .FoundFiles.Count
         Set myDoc = Documents.Open(FileName:=.FoundFiles(i), Visible:=False)
      With myDoc
           .Range(.GoTo(wdGoToPage, wdGoToNext, , 7).Start, VBA.IIf(7 >= .GoTo(wdGoToPage, wdGoToNext, , 7).Information _
                                (wdNumberOfPagesInDocument), .Content.End, _
                                .GoTo(wdGoToPage, wdGoToNext, , 8).Start)).Select
      End With
      'Selection.Delete
      Selection.InsertFile ("c:新建的页.doc") '注意:新页需为满页,不足要换行,否则会将第八页内容搞到第七页
      myDoc.Close True
      Next
      End If
      End With
      Application.ScreenUpdating = True
      End Sub
      上一篇:LISP函数大全
      下一篇:
      
      Powered by DLKIT 开发版 © 2011-2012 DLCMS.NET Inc.
      Copyright © 2017-2018 威廉希尔_威廉希尔官网_英国威廉希尔官网