View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T[_7_] Peter T[_7_] is offline
external usenet poster
 
Posts: 162
Default Use string variable as Object name


"John" wrote in message
...
I'd like to use a string variable as an object's name. Is this possible.
For example:

Dim strApp As String
Dim i As Integer

For i = 1 To 3

strApp = "xApp0" & intLaunchNo
Set strApp = New Excel.Application

I know this does not work as above. Any way I can get strApp to serve as
the new excel object's name?


You can't asssign an object to a string variable. Maybe something like this
for your multiple objects

Dim arrXL() as Excel.Application
Dim i as long, cnt as long
cnt = 3

Redim arrXL(1 to cnt)

For i = 1 to cnt
Set arrXL(i) = New Excel.Application

No idea what you're really trying to do so if an array is no good look into
use of storing an object pointer and retreiving to an object variable, or
CallByName perhaps

I can't imagine why you want to start 3 new instances though!

Regards,
Peter T