Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word and Excel constants

Status
Not open for further replies.

RPrinceton

Programmer
Jan 8, 2003
86
US
Hi,
I see constants like wdSaveChanges and xlMaximized all over the place. However what I don't see is one place that lists them all. Can anyone tell me where I can get the full list of both the Word and Excel constants?
Please advise. Thx in advance.
Regards,
RPrinceton
 

There isn't really a full list that I know of but you should be able to see them all in the Object Browser.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Go to:

Word Constants for an enumeration of all Word constants in the 2003 Object Model.

The web reference is handy, but I found I wanted them more available, so I copied and pasted them into my own document. There used to be a downloadable document, but it seems to be no longer available.



Gerry
 
Hi TonyJollans and fumei,
I did a little more research. I found some code that extracts the constants. I modified the code to insert the constants along with their respective values into an Excel spreadsheet one sheet per MS Office application. I have included my VB6 code below to share with anyone who is interested.
Regards,
RPrinceton

VB6 code:
Private Sub cmdExtract_Click()
Dim AppArr() As String
Dim MSApps() As String
Dim NOP As Boolean
Dim appsMax As Integer
Dim c As Long
Dim i As Long
Dim mbr As Object
Dim newBook As Workbook
Dim objConst As Object
Dim objFile As TLI.TypeLibInfo 'a reference to TLBINF32.DLL is required
Dim r As Long
Dim savePath As String
Dim y As Integer

INIFile1.FileName = App.Path & "\ExtractMSConstants.INI"
INIFile1.Section = "ExtractMSConstants"
INIFile1.Entry = "NumberofApps"
INIFile1.ReadEntry
appsMax = INIFile1.Value ' get number of MS Office applications
ReDim MSApps(appsMax) 'allocate array based on number of MS Office apps

For y = 0 To appsMax
INIFile1.Entry = "MSApp" & y
INIFile1.ReadEntry
MSApps(y) = INIFile1.Value ' store the paths to the .OLB files
Next y

INIFile1.Entry = "SavePath"
INIFile1.ReadEntry
savePath = INIFile1.Value ' get the name of the Excel file to save the constants to

' Excel defaults to 3 sheets when adding a workbook
' add extra sheets based on the number of MS Office apps
Set newBook = Workbooks.Add
Select Case True
Case appsMax > 3
With newBook
.Title = "MS Office Constants"
.Worksheets.Add Count:=appsMax - 3
End With
Case Else
With newBook
.Title = "MS Office Constants"
End With
End Select

Screen.MousePointer = vbHourglass
For y = 0 To UBound(MSApps) - 1
AppArr = Split(MSApps(y), "|")
Set objFile = TypeLibInfoFromFile(Trim(AppArr(1)))
With Worksheets(y + 1).Columns("A")
.ColumnWidth = .ColumnWidth * 3#
End With
With Worksheets(y + 1)
.Name = Trim(AppArr(0)) 'name each sheet based on the constants being extracted
End With
lblMsg.Caption = Trim(AppArr(0)) & " constants are being extracted"
DoEvents
c = 1
r = 1
For Each objConst In objFile.Constants
For Each mbr In objConst.Members
Select Case r
Case 1
With Worksheets(y + 1).Cells(r, 1) 'move column heading in
.Value = "Constant"
End With
With Worksheets(y + 1).Cells(r, 2) 'move column heading in
.Value = "Value"
End With
Case Else
NOP = True
End Select
c = 1
r = r + 1
With Worksheets(y + 1).Cells(r, c)
.Value = mbr.Name 'insert constant's name
End With
c = c + 1
With Worksheets(y + 1).Cells(r, c)
.Value = mbr.Value 'insert the contant's value
End With
Next mbr
Next objConst
Set objFile = Nothing
Next y
ActiveWorkbook.SaveCopyAs savePath
Set newBook = Nothing
Screen.MousePointer = vbNormal
lblMsg.Caption = "MS Office App constants extracted"
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top