Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can you instantiate classes without hard-coding class names??


I would like to instantiate classes, which I have written in Excel VBA,
without hard-coding class names..

For example, the following code could set obj to a particular
CodeModule.

Set obj = thisWorkbook.VBProject.VBComponents(indx)

But I really need to instantiate the class that the module represents.
I.e.,

Set obj = new classname
, where classname is thisWorkbook.VBProject.VBComponents(indx).Name.

Any ideas? (If I could accomplish this, it would allow the application
to query all classes in the Class Modules and choose appropriate
classes to process. Hard-coding requires additional redundant code
every time new classes are added.)

Thanks


--
ALittle
------------------------------------------------------------------------
ALittle's Profile: http://www.excelforum.com/member.php...o&userid=28695
View this thread: http://www.excelforum.com/showthread...hreadid=487484

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can you instantiate classes without hard-coding class names??


Hello Alittle,

Could you provide a better code example of what you are trying to
accomplish?

Thanks,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=487484

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can you instantiate classes without hard-coding class names??


Actually, no. I cannot provide code. That’s what I am looking for.

I want to do the equivalent of

Set obj = new classname

However, the name of any actual class (e.g., classname) is not know
during programming, so the above statement cannot be hard coded. It i
only during program execution that actual class names are known.

This may not be possible except through slight of hand, which I woul
like to avoid.

Possible solutions that I might be forced to try would include:
-- using some type of immediate execution code to execute a characte
string statement or
-- writing code to a class module and then executing that code

--
ALittl
-----------------------------------------------------------------------
ALittle's Profile: http://www.excelforum.com/member.php...fo&userid=2869
View this thread: http://www.excelforum.com/showthread.php?threadid=48748

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
hard coding a cell darrelly Excel Discussion (Misc queries) 2 October 7th 05 11:24 PM
User-changeable paths into Excel - avoid hard coding gearoi[_3_] Excel Programming 11 August 31st 05 03:10 PM
Hidding Macro names and coding mrbalaje Excel Discussion (Misc queries) 4 April 20th 05 04:23 PM
Instantiate a Class via Automation Mark Excel Programming 0 March 17th 05 03:31 AM
Hard-Coding a File Location ibeetb Excel Programming 1 April 15th 04 06:46 PM


All times are GMT +1. The time now is 01:35 AM.

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"