PDA

View Full Version : Access DB to check Word File Setting



scottpon
10-15-2019, 12:54 PM
I'm trying to check and set over 300 MS Word documents. I'm using MS Access VBA to go to the folder, open each file check the setting, set if necessary and then close the file. I did something similar before in in Access so I hope I can do this too.

In Word, I go File->Options->Add-ins-> Manage Templates [Go...] to get to this dialog box:
25284

I am able to get Document template using doc.AttachedTemplate.FullName (doc represents the word file. you can see my code below)
however, i'm trying to get the checkbox "Automatically update document styles" Does anyone know what the variable/property name is for that field?

Here's my code so far.


Private Sub ListFiles(mysourcePath As String, extension As String)
Set MyObject = New Scripting.filesystemobject
Set MySource = MyObject.getfolder(mysourcePath)
On Error GoTo errhandler ' Resume Next
For Each Myfile In MySource.Files
MyFilename = Trim(Myfile.Name)
If InStr(1, MyFilename, "~") = 0 Then
' temp character not found
If InStr(1, MyFilename, "." & extension) Then
Call ProcessWordFile(MyFilename)
End If
End If
Next
exit sub



Private Sub ProcessWordFile(Filename As String)
On Error GoTo ErrorHandling
Dim appWord As Word.Application
Dim doc As Word.Document
Dim strDocName As String
Dim TemplateName As String
Dim LinkedStyles As String
Dim MyStyle As Style
strDocName = MI_Path & "" & Filename

' Open the word file
Set appWord = GetObject(, "Word.Application")
Set doc = appWord.Documents.Open(strDocName, , True)

TemplateName = doc.AttachedTemplate.FullName
' CheckboxValue =
' How do I get that checkbox here???


doc.Close ' Close the Word File
end sub


Again, my main objective is trying to get the property name for "Automatically update document styles". From there i can determine what I have to do next.

THanks.

OBP
10-15-2019, 01:07 PM
I would suggest posting a small post on the Word Forum just asking if anyone knows the VBA reference for that checkbox.
I know a little Word VBA, but concentrate on Access, so I can't help you.
ps I would suggest that when you get it's reference you will need to refer to it
With TemplateName
.checkboxreference.value = -1' probably -1 like Access checkboxes.
end with

scottpon
10-15-2019, 01:14 PM
I would suggest posting a small post on the Word Forum just asking if anyone knows the VBA reference for that checkbox.
I know a little Word VBA, but concentrate on Access, so I can't help you.
ps I would suggest that when you get it's reference you will need to refer to it
With TemplateName
.checkboxreference.value = -1' probably -1 like Access checkboxes.
end with

Will do. I don't really think of Word as being programmable. lol.

scottpon
10-22-2019, 02:56 PM
I got a response it is this:

ActiveDocument.UpdateStylesOnOpen = True