Access Beginner
Active Member
- Joined
- Nov 8, 2010
- Messages
- 311
- Office Version
- 2016
- Platform
- 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.
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