Helmut said:
Hi,
yes, you are right,
here and now, according to my specifications,
First point, filesearch returns the fullname,
like "c:\test\test.mydoc.doc"
Second point, it returns fullnames,
that contain an "S" or "s", unexpectedly,
and I don't know about case sensitivity here,
it is a mystery.
So, try this one:
Sub Makro2()
Dim l As Long
Dim s As String
With Application.FileSearch
.FileName = "S*.doc"
.LookIn = "c:\"
.SearchSubFolders = True
.Execute
For l = 1 To .FoundFiles.Count
s = StrReverse(.FoundFiles(l))
s = Left(s, InStr(s, "\"))
s = Left(s, Len(s) - 1)
s = StrReverse(s)
If Left(s, 1) = "s" Or Left(s, 1) = "S" Then
Selection.TypeText s & vbCr
End If
Next
End With
End Sub
If you need help for putting the result into an array,
ask again.
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
Many thanks Helmut, since I'm a 67 year old pensioner without a lot of
knowledge of vba and trying to help my daughter with WORD may I push my
luck and ask you how I would insert your sub into:--
Sub ChangeTemplateToNormal()
Call macro_running
'Application.DisplayAlerts = False
'AnimateScreenMovements = False
'ScreenUpdating = False
'Application.Visible = False
Dim oForm As Object
Dim i As Integer
' Dim i As Long
Dim varFile As Variant
'UserForm1.Show
With Application.FileSearch
'*** select files ********************************
..FileName = "*.doc"
..LookIn = "\\server2\cvs\L_R"
..SearchSubFolders = False
..Execute
For Each varFile In .FoundFiles
With Documents.Open(FileName:=varFile,
ConfirmConversions:=False)
On Error GoTo z
..UpdateStylesOnOpen = False
..AttachedTemplate = "normal"
..Save
..Close SaveChanges:=wdSaveChanges
'Application.StatusBar = varFile
Close
End With
qq:
Next varFile
End With
GoTo x
'Application.StatusBar = varFile
ScreenUpdating = True
AnimateScreenMovements = False
Application.Visible = True
z:
MsgBox "Bad document,click OK, see next message box for document
name,move it somewhere else and run macro again"
MsgBox varFile
GoTo qq
Application.StatusBar = varFile
x:
'Unload UserForm1
Call macro_finished
Application.Quit SaveChanges:=wdPromptToSaveChanges
End Sub