ActiveDocument.Styles("Normal").ParagraphFormat.LineSpacingRule = "wdLineSpaceMultiple"
His solution involved a lot of copy/paste operations and some nifty code that created a function with a big Select Case statement for performing the look-up (translation) of the character string into the numeric value of the instrinsic enumeration item.
Public Function GetOLBenums() As Object
Dim oTLI As New TLI.TypeLibInfo
Dim sText As String
Dim strProgFiles As String
'Set oTLI = CreateObject("TLI.TLIApplication")
Dim oConstantsGroup, oEnum
Dim oDic As Object
Dim DicAppLibs As Object
Dim strOfficePath As String
Dim vItem As Variant
Dim vProgFile As Variant
Dim oFS As Object
Dim boolOLBFound As Boolean
Set oFS = CreateObject("scripting.filesystemobject")
Set DicAppLibs = CreateObject("scripting.dictionary")
Set oDic = CreateObject("scripting.dictionary")
oDic.CompareMode = vbTextCompare '=1
DicAppLibs("Microsoft Access") = "Msacc.olb"
DicAppLibs("Microsoft Excel") = "EXCEL.EXE"
DicAppLibs("Microsoft Graph") = "Graph.exe"
DicAppLibs("Microsoft Office") = "MSO.dll"
DicAppLibs("Microsoft Outlook") = "MSOutl.olb"
DicAppLibs("Microsoft PowerPoint") = "MSPpt.olb"
DicAppLibs("Microsoft Word") = "MSWord.olb"
'Different %ProgramFiles% environment variables in different Windows versions
'ProgramFiles=C:\Program Files
'ProgramFiles(x86)=C:\Program Files (x86)
'ProgramW6432=C:\Program Files
For Each vProgFile In Array("ProgramFiles", "ProgramFiles(x86)", "ProgramW6432")
strProgFiles = Environ(vProgFile)
If Len(strProgFiles) <> 0 Then
Exit For
End If
Next
'Different Office OLB paths
'Office 2003 C:\Program Files\Microsoft Office\Office11
'Office 2007 C:\Program Files\Microsoft Office\Office12
'Office 2010 C:\Program Files\Microsoft Office\Office14
'Office 2013 C:\Program Files\Microsoft Office\Office15
'Office 2013 C:\Program Files\Microsoft Office15\root\Office15
'Note: last one after Office365 installation
boolOLBFound = False
For Each vProgFile In Array("Microsoft Office\Office%ver%", "Microsoft Office%ver%\root\Office%ver%")
strOfficePath = Replace(vProgFile, "%ver%", Int(Application.Version))
strOfficePath = strProgFiles & "\" & strOfficePath & "\" & DicAppLibs(Application.Name)
If oFS.fileexists(strOfficePath) Then
boolOLBFound = True
Exit For
End If
Next
If boolOLBFound Then
Else
MsgBox "Unsupported Office version"
Set GetOLBenums = Nothing
Exit Function
End If
On Error Resume Next
'Get information from the current application library (currently executing version)
oTLI.ContainingFile = strOfficePath
For Each oConstantsGroup In oTLI.Constants
For Each oEnum In oConstantsGroup.Members
oDic(oEnum.Name) = oEnum.Value
Next
Next
Set GetOLBenums = oDic
End Function
Sub testOLBenums()
Dim AppEnums As Object
Dim vItem As Variant
Set AppEnums = GetOLBenums
'For demonstration purposes only
'Comment or delete the following For Each loop in production
For Each vItem In AppEnums
Debug.Print vItem, AppEnums(vItem)
Next
End Sub
xlAll -4104
xlAutomatic -4105
xlBoth 1
xlCenter -4108
xlChecker 9
xlCircle 8
xlCorner 2
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)