|
回复 4楼 kqbt 的帖子
一直在网上学习高手的帖子,很有收获。
以下代码在运行到“ With Application.FileSearch”时提示“此命令无法用于此平台”
请高手给解释一下。
原贴的题目为“怎样用Word VBA删除文档的第一行到第三行?”:
Sub kqbt_DelPar()
Application.ScreenUpdating = False
Dim MyPath As String, i As Integer, myDoc As 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)
myDoc.Range(myDoc.Paragraphs(1).Range.Start, myDoc.Paragraphs(3).Range.End).Delete
myDoc.Close True
Next
End If
End With
Application.ScreenUpdating = True
End Sub |
|