OK, really, I have tried looking. Can anyone tell me the syntax for TextOrProperty using Application.FileSearch.
From Help:
"Returns or sets the word or phrase to be searched for, in either the body of a file or the file's properties, during the file search."
Except ALL the examples I have found googling like mad, searching MSDN like mad, use text IN the document.
I know how to use TextOrProperty using a text string within the file. However, WHAT is the syntax for searching a file property???? TextOrProperty is itself a string, so I have tried:
"Number of Pages"
"Author"
"DocProperty(Author)"
yadda yadda
Say it is the Subject file property. The Subject property = "Can I really do it?". It is real. The file property IS that.
.TextOrProperty = "Can I really do it?" will NOT find the file.
It darn well always looks for a text string IN the file. I want to find a file property value.
I am missing something in the syntax, but I darn well can not figure it out, and I can not find a single example of a file property use. Just text IN a file.
Grrrrrr.
Oh......never mind. I finally figured it out. You need to use not TextOrProperty - although you'd think if it uses file properties, then you COULD - but make a PropertyTest. Like this:
will give me a list of all .doc files with Subjects that start with "Can".
Whew.....finally.
However, if someone DOES know a different syntax with TextOrProperty that actually uses a property, I would like to know it.
faq219-2884
Gerry
My paintings and sculpture
From Help:
"Returns or sets the word or phrase to be searched for, in either the body of a file or the file's properties, during the file search."
Except ALL the examples I have found googling like mad, searching MSDN like mad, use text IN the document.
I know how to use TextOrProperty using a text string within the file. However, WHAT is the syntax for searching a file property???? TextOrProperty is itself a string, so I have tried:
"Number of Pages"
"Author"
"DocProperty(Author)"
yadda yadda
Say it is the Subject file property. The Subject property = "Can I really do it?". It is real. The file property IS that.
.TextOrProperty = "Can I really do it?" will NOT find the file.
It darn well always looks for a text string IN the file. I want to find a file property value.
I am missing something in the syntax, but I darn well can not figure it out, and I can not find a single example of a file property use. Just text IN a file.
Grrrrrr.
Oh......never mind. I finally figured it out. You need to use not TextOrProperty - although you'd think if it uses file properties, then you COULD - but make a PropertyTest. Like this:
Code:
Dim StartLocation As String
Dim msg As String
Dim var
StartLocation = "C:\Test\test2"
With Application.FileSearch
.NewSearch
.LookIn = StartLocation
.FileName = "*.doc"
.FileType = msoFileTypeAllFiles
.PropertyTests.Add Name:="Subject", _
Condition:=msoConditionBeginsWith, _
Value:="Can"
.Execute
End With
If Application.FileSearch.FoundFiles.Count > 0 Then
For var = 1 To Application.FileSearch.FoundFiles.Count
msg = msg & Application.FileSearch.FoundFiles(var) & _
vbCrLf
Next
MsgBox msg
Else
Msgbox "Nope, no files in that folder have a Subject starting with Can."
End If
Whew.....finally.
However, if someone DOES know a different syntax with TextOrProperty that actually uses a property, I would like to know it.
faq219-2884
Gerry
My paintings and sculpture