View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default xlConstants to numbers?

Is is possible to get this converted into the number of the xlConstant?
you'd need to programmatically write code to a module

But you can get one or all of the constants directly from Excel's typelib


Sub dumpConstants()
''' with a reference to TypLib Information
'Dim oTLI As TLI.TLIApplication
'Dim oInfo As TLI.TypeLibInfo
'Dim oConst As TLI.ConstantInfo
'Dim oMembers As TLI.Members

''' without the reference use As Object
Dim oTLI As Object
Dim oInfo As Object
Dim oConst As Object
Dim oMembers As Object

Dim i As Long, c As Long

Set oTLI = CreateObject("TLI.TLIApplication")
Set oInfo = oTLI.TypeLibInfoFromFile(Application.Path & "\Excel.exe")

For Each oConst In oInfo.Constants
i = i + 1
Cells(i, 1) = oConst.Name
Set oMembers = oConst.Members
For c = 1 To oMembers.Count
i = i + 1
Cells(i, 2) = oMembers(c).Name
Cells(i, 3) = oMembers(c).Value
Next
Next

Columns("A:C").EntireColumn.AutoFit
End Sub

Regards,
Peter T


"Charlotte E." <@ wrote in message
...
In a cell, say "B3", I have one of the VBA xlConstants as written text,
say 'xlDialogActivate'.

Is is possible to get this converted into the number of the xlConstant?

I've tried...


MsgBox Evaluate(Range("B3").value)


But with no luck :-(


Any other way to get this done?


TIA,

CE