1, on the need to change the document folder has set up a *. Docx (office2013 document),
2, through the development tool to set up a control button, double-click the code is as follows:
Private Sub CommandButton1_Click ()
Application. ScreenUpdating=False
Dim myPas As String, myPath As String, I As an Integer, myDoc As Document
With the Application. The FileDialog (msoFileDialogFolderPicker)
The Title="select a target folder"
If the Show=1 Then
MyPath=. SelectedItems (1)
The Else
The Exit Sub
End the If
End With
Open myPas=InputBox (" please enter the password: ")
With the Application. The FileSearch
. LookIn=myPath
The FileType=msoFileTypeWordDocuments
If the Execute & gt; 0 Then
For I=1 To. FoundFiles. Count
The Set myDoc=Documents. The Open (FileName:=FoundFiles (I), Passworddocument:=myPas)
Selection. The Find. ClearFormatting
Selection. The Find. Replacement. ClearFormatting
With the Selection. The Find
The Text="Liu Yanhuan"
. Replacement. Text=""
The Forward=True
The Wrap=wdFindAsk
. The Format=False
The MatchCase=False
. MatchWholeWord=False
. MatchByte=True
. MatchWildcards=False
. MatchSoundsLike=False
. MatchAllWordForms=False
End With
Selection. The Find. Execute the Replace:=wdReplaceAll
MyDoc. Save
MyDoc. Close
The Set myDoc=Nothing
Next
End the If
End With
Application. ScreenUpdating=True
End Sub
Cancel the design pattern, after operation, select the folder, enter the password after an error code 5111,
When debugging found with application. Filesearch yellow shows in the platform is not available,
Master for such a small white, I hope you can help,
CodePudding user response:
With cannot be nested. Only one floor.CodePudding user response:
Yes, can't use, your code can only be used in 2003,Or you look for it again, more online code,
CodePudding user response: