I'm working on creating a form/database in Excel of
specific files in Word. Rather than typing in the names of
the files, I'd like to copy and paste the list of files.
For some reason, the only option I have is to print. I
don't want an image...I want a list in text format. Any
suggestions? Many thanks.
OK, this is the wrong group for this. Sorry everyone.
Lucy, try this:-
Sub ListWordFiles()
Dim PathName As String
Dim PathNameFile As String
Dim FolderFiles() As String
Dim TheFile As String
Dim FCount As Integer
Dim RangeX As String
PathName = <"My Path Name">
PathNameFile = PathName + "*.*"
FCount = 0
TheFile = Dir(PathNameFile)
While TheFile <> Empty
FCount = FCount + 1
ReDim Preserve FolderFiles(1 To FCount)
' declares the array variable again (size+1)
TheFile = PathName + "\" + TheFile
FolderFiles(FCount) = TheFile
TheFile = Dir
Wend
Worksheets("Sheet1").Activate
ActiveSheet.Cells.ClearContents
Cells(1, 1).Activate
For i = 1 To FCount
If Right(FolderFiles(i), 4) = ".doc" Then
ActiveCell.Value = FolderFiles(i)
ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate
End If
Next i
RangeX = "A1:A" + Format(FCount)
Range(RangeX).Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Erase FolderFiles ' deletes the varible contents, free some memory
Cells(1, 1).Select
End Sub
You'll have to replace <"My Path Name"> with wherever your .doc files are.
--
John Thow
an optimist is a guy/ that has never had/ much experience -
certain maxims of archie; Don Marquis.
To e-mail me, replace the DOTs in the Reply-To: address with dots!