none
Cannot find wdStyle enum for "Table Grid" RRS feed

  • Question

  • MS Word has internal names it uses for styles. All builtin styles are supposed to have them and when writing code for multi language deployment, you must use the wdStyle enum rather than a local name.  I have found the MS documentation for this on line and could not find (or determine) what the wdstyle enum for "Table Grid" is among the various table grid styles listed.  Does anyone know how to find that information?
    Thanks in advance.

    karl

    Monday, June 3, 2019 1:47 PM

Answers

  • A problem with Word is that some enums are more complete than others.

    In this case, the wdBuiltinStyle enum does not actually have a named value for -155, which is the value you need for "Table Grid"

    How to find that out? Trial and error , really, e.g. apply "Table Grid" table style to the first table in a document and run a bit of VBA like this:

    Sub findstyleid()
    Dim i As Integer
    On Error Resume Next
    For i = -1 To -1000 Step -1
      ActiveDocument.Tables(1).Style = i
      If Err.Number = 5849 Then
        Err.Clear
      ElseIf ActiveDocument.Tables(1).Style = "Table Grid" Then
        Debug.Print i, ActiveDocument.Tables(1).Style
        DoEvents
      End If
    Next
    End Sub
    




    Peter Jamieson

    • Marked as answer by BitsnPCES Monday, June 3, 2019 5:08 PM
    Monday, June 3, 2019 3:44 PM

All replies

  • A problem with Word is that some enums are more complete than others.

    In this case, the wdBuiltinStyle enum does not actually have a named value for -155, which is the value you need for "Table Grid"

    How to find that out? Trial and error , really, e.g. apply "Table Grid" table style to the first table in a document and run a bit of VBA like this:

    Sub findstyleid()
    Dim i As Integer
    On Error Resume Next
    For i = -1 To -1000 Step -1
      ActiveDocument.Tables(1).Style = i
      If Err.Number = 5849 Then
        Err.Clear
      ElseIf ActiveDocument.Tables(1).Style = "Table Grid" Then
        Debug.Print i, ActiveDocument.Tables(1).Style
        DoEvents
      End If
    Next
    End Sub
    




    Peter Jamieson

    • Marked as answer by BitsnPCES Monday, June 3, 2019 5:08 PM
    Monday, June 3, 2019 3:44 PM
  • Thanks for your response, Peter. Word falls just a little short once again. I probably should have done what you did but I admit thinking "Microsoft really doesn't want us doing that to find the enum name. I must just be looking in the wrong place." :-)

    karl

    Monday, June 3, 2019 5:08 PM