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

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,215,786
Messages
6,126,891
Members
449,347
Latest member
Macro_learner

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