PDA

View Full Version : Set TextOrProperty attribute change the name of company



mibushk
10-16-2009, 04:40 AM
Hello,

:banghead: I have around 500 files (excell, word, powerpoint) which have as property in company field one name.
I managed with Filesearch funtion to list the documeents that have the " John" attribute, and now I have to set the attribute to "Mary"

I do not know how to do it,

I attach what I have done till now:



Public Sub cmdFileSearch1_click()
Dim field As String

Set fs = Application.FileSearch
With fs
.LookIn = "D:\PSAD_Process"
.SearchSubFolders = True
.TextOrProperty = "*john*"
If .Execute(SortBy:=msoSortByFileName, SortOrder:=msoSortOrderAscending) > 0 Then
thisFile = 1
field = .TextOrProperty
For i = 1 To .FoundFiles.Count
afile = .FoundFiles(i)

If afile <> ThisWorkbook.Path & "\" & ThisWorkbook.Name Then

'MsgBox .TextOrProperty
ActiveSheet.Cells(i, 3).Value = afile
ActiveSheet.Cells(i, 4).Value = field

End If
Next i

Else
MsgBox "There were no files found."
End If
End With
End Sub

please help

parttime_guy
10-16-2009, 08:27 PM
Hi MiBush,
Try this "kb"

http://www.vbaexpress.com/kb/getarticle.php?kb_id=800

Hope this helps....
Best regards

mdmackillop
10-17-2009, 03:31 AM
You could hardcode it

Dim ToFind as String
Dim Arr, a
Arr = Array("John", "Mary")
For Each a In Arr
ToFind = "*" & a & "*"
With fs
'etc.
Next


or ask for user input

Dim ToFind As String
ToFind = "*" & InputBox("String to search") & "*"

then change this line to use the variable

.TextOrProperty = ToFind

mibushk
10-18-2009, 11:30 PM
thank you so much for your replies, but I would like to modify "John" to "Mary"
I am able to see all my files that have "John" as property field, but now I would like to set it to "Mary"

sorry to take time from you but I am asked to finish this soon, and I am now stuck:( I have asked around here in my office and nobody know how to do it, only open each document and set it by "hand":(:(

parttime_guy
10-20-2009, 01:41 AM
Hope this helps

The MS Link

http://support.microsoft.com/kb/320167


Some Freeware available on the Net

http://www.snapfiles.com/Freeware/system/fwfilerename.html
http://www.bulkrenameutility.co.uk/Main_Intro.php
http://www.thefreecountry.com/utilities/batch-file-renaming.shtml
http://www.joejoesoft.com/cms/showpage.php?cid=108