Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default return text not index for property


Hi all
A simple question, I hope
how do I return the name rather than the index number for a property,
so that eg

MsgBox ActiveWorkbook.FileFormat

returns "xlWKS" not "39"


--
Nicky


------------------------------------------------------------------------
Nicky's Profile: http://www.excelforum.com/member.php...nfo&userid=312
View this thread: http://www.excelforum.com/showthread...hreadid=380800

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default return text not index for property

It may be a simple question, but it is a complicated answer. And
by the way, xlWKS is a 4, not a 39. First, in VBA go to the Tools
menu, choose References, and scroll down to "Typelib
Information". If you don't have this, then you can't do what you
want. Assuming you do have this library, check it in the list.
Then use code like the following:


Dim TLIApp As TLI.TLIApplication
Dim TLILibInfo As TLI.TypeLibInfo
Dim ConstInfo As TLI.ConstantInfo
Dim MemInfo As TLI.MemberInfo

Set TLIApp = New TLI.TLIApplication
Set TLILibInfo = TLIApp.TypeLibInfoFromFile( _
Filename:=ThisWorkbook.VBProject.References("EXCEL ").FullPath)
Set ConstInfo = TLILibInfo.Constants.NamedItem("XLFileFormat")
'change
' the XLFileFormat to the constant enum group name you want
to search
For Each MemInfo In ConstInfo.Members
If MemInfo.Value = 39 Then ' change the 39 to the value you
want to look up
MsgBox MemInfo.Name
Exit For
End If
Next MemInfo


For much more information about how to do this and more, go to
http://www.cpearson.com/excel/download.htm and download TLIUtils.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com












"Nicky"
wrote in message
...

Hi all
A simple question, I hope
how do I return the name rather than the index number for a
property,
so that eg

MsgBox ActiveWorkbook.FileFormat

returns "xlWKS" not "39"


--
Nicky


------------------------------------------------------------------------
Nicky's Profile:
http://www.excelforum.com/member.php...nfo&userid=312
View this thread:
http://www.excelforum.com/showthread...hreadid=380800



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default return text not index for property


Thanks Chip, that worked perfectly, though more complicated than I'd
expected.

for anyone repeating Chip's method, you'll also need to change macro
security to include the VB project as a tructed source

Nicky


--
Nicky


------------------------------------------------------------------------
Nicky's Profile: http://www.excelforum.com/member.php...nfo&userid=312
View this thread: http://www.excelforum.com/showthread...hreadid=380800

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default return text not index for property


sorry Try
MsgBox ActiveWorkbook.Name

Should be the good one!


Nicky Wrote:
Hi all
A simple question, I hope
how do I return the name rather than the index number for a property
so that eg

MsgBox ActiveWorkbook.FileFormat

returns "xlWKS" not "39


--
Sibili
-----------------------------------------------------------------------
Sibilia's Profile: http://www.excelforum.com/member.php...fo&userid=2136
View this thread: http://www.excelforum.com/showthread.php?threadid=38080

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
return text not index for property Sibilia[_4_] Excel Programming 0 June 21st 05 11:05 AM
Return value of Property Get when using enumerated type jason Excel Programming 3 August 23rd 04 01:13 PM
Runtime Error 381 Couldn't set list property, invalid array index Newbillian Excel Programming 2 June 17th 04 11:25 AM
Runtime Error 381 Couldn't set list property, invalid array index Newbillian Excel Programming 0 June 16th 04 11:28 PM
no tab index property in VBA for text fields Kevin Mitchell Excel Programming 2 February 20th 04 03:52 PM


All times are GMT +1. The time now is 12:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"