Results 1 to 3 of 3

Thread: [RESOLVED] Making an array a for each capable object

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Resolved [RESOLVED] Making an array a for each capable object

    VB Code:
    1. Dim Arr(0 To 4) as String, Obj As Object, Stri
    2. Arr(0) = "zero"
    3. Arr(1) = "one"
    4. Arr(2) = "two"
    5. Arr(3) = "three"
    6. 'looking to make the below sub
    7. ArrToObj Arr, Obj
    8. For Each Stri In Obj
    9.     Debug.Print Stri
    10. Next

  2. #2
    Frenzied Member oh1mie's Avatar
    Join Date
    Sep 2001
    Location
    Finland
    Posts
    1,043

    Re: Making an array a for each capable object

    Are you looking something like this?

    VB Code:
    1. Dim Arr      As Collection
    2. Dim MyObject As Object
    3. Dim i        As Integer
    4.  
    5. Set Arr = New Collection
    6.  
    7. Arr.Add CreateObject("Excel.Application")
    8. Arr.Add CreateObject("Word.Application")
    9.  
    10. For i = 1 To Arr.Count
    11.     Debug.Print Arr.Item(i)
    12. Next
    13.  
    14. For Each MyObject In Arr
    15.     Debug.Print MyObject
    16. Next
    oh1mie/Vic


  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Re: Making an array a for each capable object

    Works perfectly. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width