Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
Use string variable as Object name
Peter, the array worked. Thanks so much!
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Run-time error 91: Object Variable or With block variable not set | Excel Programming | |||
Object Variable Not Set Error on Selection object | Excel Worksheet Functions | |||
Run-Time error '91': Object variable of With block variable not set | Excel Programming | |||
Run-time error '91': "Object variable or With block variable not set | Excel Programming | |||
Cells.Find error Object variable or With block variable not set | Excel Programming |