Home > Software engineering >  With the Application. The filesearch in this platform is not available
With the Application. The filesearch in this platform is not available

Time:10-23

Due to work needs, more than a folder inside the word document to replace a content, from the evening to a VB code, want to control button for replacement, but because of my is office15, so he wrote a question:
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:

reference 1st floor WallesCai response:
with cannot be nested. Only one floor.

Can be nested,

Office 15, have Application FileSearch this object?
Anyway I Office12 (2007), there is no,

CodePudding user response:

reference Chen8013 reply: 3/f
Quote: refer to 1st floor WallesCai response:

With cannot be nested. Only one floor.

Can be nested,



You can? Said I used to have seen only one layer. So never used nested.
  • Related