Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jul 2008
    Suffolk, United Kingdom
    Thanked 0 Times in 0 Posts

    multiple source directories (2003)


    At the moment I have some code that opens a dialog to allow me to choose a source folder, then asks if I want to add another it does this upto 10 times useing the If statement then moves on to sleceting the destination folder.


    I have had to copy and paste code 10 times to get this to happen, and its limited to 10 selections. I then had to paste the outcome code for the if statment 10 times. This then copies known dulicated source files into one directory from many source folders

    Is there a way to right the code once, and somehow remember the locations and create fore example strsource1 = ??? strSource2 = ???? etc etc

    Many thanks
    Gerbil (AKA Kevin)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: multiple source directories (2003)

    Wouldn't it be easier to use just one source folder in the macro, and let the user run the macro as many times as there are source folders?

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Silicon Valley, USA
    Thanked 94 Times in 90 Posts

    Re: multiple source directories (2003)

    I saw that code in another thread and wondered why you had so many repetitions. If you want to gather a list of items, you can create an array. If you don't know how many items you will need, you can create a dynamic array and give it a large initial size, and then check before each addition as to whether the array needs to be enlarged.

    Microsoft has some documentation on arrays in VBA here: Understanding Arrays @ MSDN

    You can see an example using a dynamic array and enlarging it as needed in: <post:=579,666>post 579,666</post:>.

Posting Permissions

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