Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Use string variable as Object name

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Use string variable as Object name


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


Thanks Peter. I'll try this out. I'm creating multiple instances for a work project---I'm running a report in multiple instances for performance reasons. I need to loop thru (let's say) 5 instances and open the WB in each instance.

I want to loop instead of doing xlApp01, xlApp02... Maybe I can see if the array approach will allow this.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Use string variable as Object name

Peter, the array worked. Thanks so much!
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
Run-time error 91: Object Variable or With block variable not set Ayo Excel Programming 1 August 17th 09 11:29 PM
Object Variable Not Set Error on Selection object Jean Excel Worksheet Functions 3 July 24th 06 06:45 PM
Run-Time error '91': Object variable of With block variable not set jammin1911 Excel Programming 3 June 6th 06 06:36 PM
Run-time error '91': "Object variable or With block variable not set Mike[_92_] Excel Programming 2 December 30th 04 10:59 AM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM


All times are GMT +1. The time now is 02:54 PM.

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"