J
Jack Sons
Hi all,
The Word VBA code below produces a Word document with the content of a
directory.
1. I want to use it in Excel VBA in stead of Word VBA, so in a Excel VBA
module (probably in personal.xls?) producing an Excel worksheet.
2. Furthermore I want it to result in two colums. The left column with
the names of the document, a it works now, and the right column with the
dates of the most recent change of the documents. In fact just like it
appears in my Explorer.
Your help will be appreciated.
Jack Sons
The Netherlands
------------------------------------------------------------------------------------------------------------
Sub Inhoud_Directory()
Dim PathWanted As String
Dim Temp As String
Dim i As Integer
With Dialogs(wdDialogFileOpen)
.Name = "*.*"
If .Display = -1 Then
'Documents.Add
PathWanted = Options.DefaultFilePath(wdDocumentsPath)
Set newdoc = Documents.Add
With newdoc
.Content.Font.Name = "Times New Roman"
.SaveAs FileName:=PathWanted
End With
Selection.TypeText "Files in " & PathWanted & ":" & vbCrLf
With Application.FileSearch
.LookIn = PathWanted
.FileName = "*.*"
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Temp = .FoundFiles(i)
While InStr(Temp, "\") > 0
Temp = Mid(Temp, InStr(Temp, "\") + 1)
Wend
Selection.TypeText Temp & vbCrLf
Next
End If
End With
End If
End With
End Sub
The Word VBA code below produces a Word document with the content of a
directory.
1. I want to use it in Excel VBA in stead of Word VBA, so in a Excel VBA
module (probably in personal.xls?) producing an Excel worksheet.
2. Furthermore I want it to result in two colums. The left column with
the names of the document, a it works now, and the right column with the
dates of the most recent change of the documents. In fact just like it
appears in my Explorer.
Your help will be appreciated.
Jack Sons
The Netherlands
------------------------------------------------------------------------------------------------------------
Sub Inhoud_Directory()
Dim PathWanted As String
Dim Temp As String
Dim i As Integer
With Dialogs(wdDialogFileOpen)
.Name = "*.*"
If .Display = -1 Then
'Documents.Add
PathWanted = Options.DefaultFilePath(wdDocumentsPath)
Set newdoc = Documents.Add
With newdoc
.Content.Font.Name = "Times New Roman"
.SaveAs FileName:=PathWanted
End With
Selection.TypeText "Files in " & PathWanted & ":" & vbCrLf
With Application.FileSearch
.LookIn = PathWanted
.FileName = "*.*"
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Temp = .FoundFiles(i)
While InStr(Temp, "\") > 0
Temp = Mid(Temp, InStr(Temp, "\") + 1)
Wend
Selection.TypeText Temp & vbCrLf
Next
End If
End With
End If
End With
End Sub