View Single Post
 
Old 04-23-2024, 01:15 AM
anmalogo anmalogo is offline Windows 11 Office 2021
Novice
 
Join Date: Apr 2024
Posts: 8
anmalogo is on a distinguished road
Default Can you please share the macro?

Quote:
Originally Posted by wwballar42 View Post
Hello,

I am trying to see a way where I can have the custom properties defined and then have a macro to change other multiple word documents.

These custom properties are the same in all word documents, and I think its a bit much to go into each word document and change the properties. I am hoping there is a better solution to this.

I will attach the custom properties that are in the word document.
Hoping you could help me create a macro where all these custom properties can be updated once for multiple word documents.

Thanks so much for your help.

Hello wwballar42,

I have the same issue. A lot of documents all of them with the same properties, and I would like to mass update the properties for all of them.

What I'm thinking is to create an Excel macro to first list all the custom properties from all the document which in a folder and sub-folders, after all the custom properties are displayed in the Excel Sheet, modify them and mass update.

Currently what I have is a Macro to read all files and list in column 1 the file path, and in column 2, the file name. I'm currently not able to get the custom properties .

Here is the Excel VBA code mentioned above, in case someone knows how to do it.

Thanks in advance for your help.

HTML Code:
Sub getfiles()
    'Get the files name from Folder and Subfolder
    Dim oFSO As Object
    Dim oFolder As Object
    Dim oFile As Object, sf
    Dim i As Integer, colFolders As New Collection, ws As Worksheet
    Dim selectedFolder As Variant
    Dim fd As FileDialog
    
    Set ws = ActiveSheet
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    
    'Prompt user to select a folder
    Set fd = Application.FileDialog(msoFileDialogFolderPicker)
    
    With fd
        .Title = "Select Folder"
        .AllowMultiSelect = False
        If .Show = -1 Then
            selectedFolder = .SelectedItems(1)
        Else
            MsgBox "No folder selected. Operation aborted."
            Exit Sub
        End If
    End With
    
    Set oFolder = oFSO.getfolder(selectedFolder)
    
    colFolders.Add oFolder          'start with this folder
    
    Do While colFolders.Count > 0      'process all folders
        Set oFolder = colFolders(1)    'get a folder to process
        colFolders.Remove 1            'remove item at index 1
        
        For Each oFile In oFolder.Files
            If oFile.DateLastModified > Now - 7 Then
                ws.Cells(i + 1, 1) = oFolder.Path
                ws.Cells(i + 1, 2) = oFile.Name
                'ws.Cells(i + 1, 3) = oFile.DateLastModified
                i = i + 1
            End If
        Next oFile
        
        'add any subfolders to the collection for processing
        For Each sf In oFolder.subfolders
            colFolders.Add sf
        Next sf
    Loop
End Sub
Reply With Quote