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? |
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 |
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. |
Use string variable as Object name
Peter, the array worked. Thanks so much!
|
All times are GMT +1. The time now is 12:08 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com