Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Property question

Hi.

Is it possible to reference a property name using a variable?

Let's say I have a class module, clMyClass, with a string property named
"sMystring".

Now I would like to do something along this line:

Sub Example()
Dim sText as string
Dim vVar

sText = "Text to put in the property sMystring"
vVar = sMystring 'Actually I find the property name elsewhere
clMyClass.vVar = sText

End Sub

But this fails. I cannot make it work either if I use an object instead of a
variant. Any suggestions?

Regards Eric Bentzen



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Property question

Eric,

In Excel 2000 and later, you can use the CallByName function to do
this. E.g.,


Dim PropName As String
PropName = "Value"
CallByName clMyClass, PropName, vbLet, sText

See help for CallByName for more details.

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




"Eric Bentzen" wrote in message
...
Hi.

Is it possible to reference a property name using a variable?

Let's say I have a class module, clMyClass, with a string

property named
"sMystring".

Now I would like to do something along this line:

Sub Example()
Dim sText as string
Dim vVar

sText = "Text to put in the property sMystring"
vVar = sMystring 'Actually I find the property name elsewhere
clMyClass.vVar = sText

End Sub

But this fails. I cannot make it work either if I use an object

instead of a
variant. Any suggestions?

Regards Eric Bentzen





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
How to Use DateLastModified Property in VBA? HROBERTSON Excel Discussion (Misc queries) 3 May 6th 23 03:45 AM
print property cwwolfdog Excel Discussion (Misc queries) 1 April 10th 05 03:15 AM
How to get Signature property! Ahmad Jalil Qarshi Excel Discussion (Misc queries) 1 March 8th 05 01:16 PM
Question about "End(xlUp)" property Dave Peterson[_3_] Excel Programming 1 August 4th 03 04:24 AM
Question about "End(xlUp)" property Chip Pearson Excel Programming 0 August 4th 03 02:57 AM


All times are GMT +1. The time now is 06:32 AM.

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

About Us

"It's about Microsoft Excel"