Una famiglia di prodotti software per l'elaborazione di testo Microsoft per la creazione di documenti Web, messaggi di posta elettronica e stampa.
Ciao Fangio49,
copia il seguente codice in un modulo Visual Basic di un nuovo documento:
Public Sub CreaListaOggetti()
On Error GoTo ErrH
Const cstrFolder = "C:\Archivi\Forums" ' <--- Modificare
Const cstrFileExtList = "doc,docx" ' <--- Modificare se necessario
Const FMTID_SummaryInfo = "{F29F85E0-4FF9-1068-AB91-08002B27B3D9}"
Const PID_SUBJECT = "3"
Const SCID_SUBJECT = FMTID_SummaryInfo & "," & PID_SUBJECT
Const ReadOnly = &H1
Const Hidden = &H2
Dim objWdApp As Word.Application
Dim objWdDoc As Word.Document
Dim objWdTab As Word.Table
Dim fso As Object 'Scripting.FileSystemObject
Dim sh As Object 'Shell32.Shell
Dim objStartFolder As Object 'Scripting.Folder
Dim objFolder As Object 'Scripting.Folder
Dim objFile As Object 'Scripting.File
Dim objFolder2 As Object 'Shell32.Folder2
Dim objFolderItem As Object 'Shell32.ShellFolderItem
Dim blnAdd As Boolean
Dim strSubject As String
Dim lngRow As Long
Set objWdApp = GetObject(, "Word.Application")
Set objWdDoc = objWdApp.Documents.Add
With objWdDoc
Set objWdTab = .Tables.Add(.Range, 1, 2)
End With
With objWdTab
.Cell(1, 1).Range.Text = "File"
.Cell(1, 2).Range.Text = "Oggetto"
End With
Set fso = CreateObject("Scripting.FileSystemObject")
Set sh = CreateObject("Shell.Application")
Set objStartFolder = fso.GetFolder(cstrFolder)
For Each objFile In objStartFolder.Files
If Not (objFile Is Nothing) Then
With objFile
blnAdd = StrComp(.Path, ThisDocument.FullName, vbTextCompare)
If blnAdd Then blnAdd = Not ((.Attributes And ReadOnly) = ReadOnly)
If blnAdd Then blnAdd = Not ((.Attributes And Hidden) = Hidden)
If blnAdd Then
If Len(cstrFileExtList) Then
blnAdd = InStr(1 _
, "," & cstrFileExtList & "," _
, "," & fso.GetExtensionName(objFile) & "," _
, vbTextCompare) > 0
Else
blnAdd = True
End If
End If
If blnAdd Then
blnAdd = False
Set objFolder2 = sh.NameSpace(objStartFolder.Path)
If Not (objFolder2 Is Nothing) Then
Set objFolderItem = objFolder2.ParseName(.Name)
If Not (objFolderItem Is Nothing) Then
strSubject _
= objFolderItem.ExtendedProperty(SCID_SUBJECT)
With objWdTab
.Rows.Add
lngRow = .Rows.Count
.Cell(lngRow, 1).Range.Text = objFile.Name
.Cell(lngRow, 2).Range.Text = strSubject
End With
End If
End If
End If
End With
End If
Next
ExtP:
Set objFolderItem = Nothing
Set objFolder2 = Nothing
Set objFile = Nothing
Set objFolder = Nothing
Set objStartFolder = Nothing
Set sh = Nothing
Set fso = Nothing
Set objWdTab = Nothing
Set objWdDoc = Nothing
Set objWdApp = Nothing
Exit Sub
ErrH:
MsgBox Err.Description
Resume ExtP
End Sub