VBA to update Word Docs Title and Author in a folder

Access Beginner

Active Member
Joined
Nov 8, 2010
Messages
311
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

I'm trying to have code so that it will update Author, Title, Company etc of multiple Word Docs in a folder. I have found some code on the interwebs but it bugs out with "Compile Error. Object required " on "strStartPath"

The code I found hard codes the changes in the code and it would be great if these could be referenced in cells. I have 100's of these changes to make and this would save me a load of time.


Code:
Option Explicit


Sub Set_Properties()

Dim myRange As Range
Dim wdApp As Object
Dim strStartPath As String
On Error Resume Next

Dim sSearchfor As String
    'Try to establish link to open instance of Word
    Set wdApp = GetObject(, "Word.Application")
    
    'If this fails, open Word
    If wdApp Is Nothing Then
        Set wdApp = GetObject("", "Word.Application")
    End If
    On Error GoTo 0
    'stop the screen flickering
    Application.ScreenUpdating = False

 'DoEvents
 Set strStartPath = wdApp.Documents.Open("Z:\Data\Word Docs")
    With ActiveDocument

        .BuiltinDocumentProperties("Title") = "My great document"

       .BuiltinDocumentProperties("Subject") = "Word VB Help"

        .BuiltinDocumentProperties("Author") = "Carl Armbruster"

       .BuiltinDocumentProperties("Manager") = "My Boss"

       .BuiltinDocumentProperties("Company") = "Buffets, Inc."

       .BuiltinDocumentProperties("Category") = "Word Documents"

        .BuiltinDocumentProperties("Keywords") = "VB, Stuff"

      .BuiltinDocumentProperties("Comments") = "Hope this helps!"

    End With
wdApp.Visible = True
End Sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,215,563
Messages
6,125,560
Members
449,237
Latest member
Chase S

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top