Consulting

Results 1 to 4 of 4

Thread: Access DB to check Word File Setting

  1. #1
    VBAX Newbie
    Joined
    Oct 2012
    Posts
    5
    Location

    Question Access DB to check Word File Setting

    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:
    templateaddin.jpg

    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.
    Last edited by scottpon; 10-15-2019 at 01:17 PM.

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,080
    Location
    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

  3. #3
    VBAX Newbie
    Joined
    Oct 2012
    Posts
    5
    Location
    Quote Originally Posted by OBP View Post
    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.

  4. #4
    VBAX Newbie
    Joined
    Oct 2012
    Posts
    5
    Location
    I got a response it is this:
    ActiveDocument.UpdateStylesOnOpen = True

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •