+ Reply to Thread
Results 1 to 18 of 18

Open directory for multiple times to import photos

  1. #1
    Registered User
    Join Date
    03-02-2022
    Location
    Gemany
    MS-Off Ver
    365
    Posts
    13

    Exclamation Open directory for multiple times to import photos

    Hello,

    I am using the following VBA code in order to insert multiple pictures from a folder in specific cells then resize it and it is working perfect.

    The folder path is already mentioned in the code. So if I want to import photos from another folders (one after the other, not the same time), I have to open the code and change the folder path.
    Unfortunately, there is no option in the code to open a directory and select the folder I need .. then run the code again and select another folder and so on ..

    How can I do this, so when running the code I would be able to:

    1- select the folder I want to import the photos from ..
    2- repeat the same procedure with another folder

    Kindly be aware to change the folder directory while checking the code

    Thanks in advance

    Regards


    Please Login or Register  to view this content.
    Last edited by jamelh; 03-07-2022 at 03:51 PM.

  2. #2
    Forum Contributor
    Join Date
    05-09-2021
    Location
    Sweden
    MS-Off Ver
    Office 365
    Posts
    148

    Re: Open directory for multiple times to import photos

    Hello Jamelh,

    There are a couple of ways you could solve this, open many folders to copy images.

    If you know the folders, and they are all the same, I would maybe list all the folder paths in a sheet or in an array in the code.

    Another way would be to recursevely loop all folders inside the downloads folder (or whichever folder you choose). This can only be used of course, if you want to import all photos in all subfolders.
    https://www.excelhowto.com/macros/ho...use-excel-vba/

    The final way I am thinking about is what you say, a dialog to select the folder. This would be the Filedialogfilepicker.
    https://analystcave.com/vba-applicat...g-select-file/

    Hope that helps!

  3. #3
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Open directory for multiple times to import photos

    A simple possiblility...
    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor rollis13's Avatar
    Join Date
    01-26-2012
    Location
    Cordenons
    MS-Off Ver
    Excel 2016 32bit - Win 11
    Posts
    915

    Re: Open directory for multiple times to import photos

    Oh, I'm late, anyway here is what I came up with:
    Please Login or Register  to view this content.
    If you don't need to choose the folder from which you need to import the files, because you already know these names, then you could use an array and hardcode the names of the paths and loop through them.
    Last edited by rollis13; 03-03-2022 at 02:38 PM.

  5. #5
    Registered User
    Join Date
    03-02-2022
    Location
    Gemany
    MS-Off Ver
    365
    Posts
    13

    Re: Open directory for multiple times to import photos

    Hello,

    Thank you for the info. I found reading this is really helpful for me as a beginner.

    1- first suggestion, unfortunately this can't be done because the code has to be run every day for several times.
    2- I want to select 2 or 3 folder only
    3- msoFileDialogFolderPicker worked

    Thanks a lot and I appreciate your effort.

  6. #6
    Registered User
    Join Date
    03-02-2022
    Location
    Gemany
    MS-Off Ver
    365
    Posts
    13

    Re: Open directory for multiple times to import photos

    Worked perfectly
    Thanks a lot!

    In my case I am selecting the first folder, resizing the photos and then placing each picture every 50 cells downward.

    If I want to run the code for 2 or 3 folders, what would be the best way to place the pictures in selected cells ?

    for example, after running the code and selecting folder 1:

    1: picture 1 will be placed in a merged cell ex. A50
    2- picture 2 .... A80
    3- picture 3 .... A120

    then running the code for another time with another folder will place the pictures in another cells, ex. A150, A180, A210

    how to add this feature ? I hope it is clearly described

    Thanks in advance

  7. #7
    Registered User
    Join Date
    03-02-2022
    Location
    Gemany
    MS-Off Ver
    365
    Posts
    13

    Re: Open directory for multiple times to import photos

    Quote Originally Posted by MrChulo View Post
    Hello Jamelh,

    There are a couple of ways you could solve this, open many folders to copy images.

    If you know the folders, and they are all the same, I would maybe list all the folder paths in a sheet or in an array in the code.

    Another way would be to recursevely loop all folders inside the downloads folder (or whichever folder you choose). This can only be used of course, if you want to import all photos in all subfolders.


    The final way I am thinking about is what you say, a dialog to select the folder. This would be the Filedialogfilepicker.


    Hope that helps!
    Hello,

    Thank you for the info. I found reading this is really helpful for me as a beginner.

    1- first suggestion, unfortunately this can't be done because the code has to be run every day for several times.
    2- I want to select 2 or 3 folder only
    3- msoFileDialogFolderPicker worked

    Thanks a lot and I appreciate your effort.

  8. #8
    Registered User
    Join Date
    03-02-2022
    Location
    Gemany
    MS-Off Ver
    365
    Posts
    13

    Re: Open directory for multiple times to import photos

    Quote Originally Posted by dangelor View Post
    A simple possiblility...
    Please Login or Register  to view this content.
    Worked perfectly
    Thanks a lot!

    In my case I am selecting the first folder, resizing the photos and then placing each picture every 50 cells downward.

    If I want to run the code for 2 or 3 folders, what would be the best way to place the pictures in selected cells ?

    for example, after running the code and selecting folder 1:

    1: picture 1 will be placed in a merged cell ex. A50
    2- picture 2 .... A80
    3- picture 3 .... A120

    then running the code for another time with another folder will place the pictures in another cells, ex. A150, A180, A210

    how to add this feature ? I hope it is clearly described

    Thanks in advance

  9. #9
    Registered User
    Join Date
    03-02-2022
    Location
    Gemany
    MS-Off Ver
    365
    Posts
    13

    Re: Open directory for multiple times to import photos

    Quote Originally Posted by rollis13 View Post
    Oh, I'm late, anyway here is what I came up with:
    Please Login or Register  to view this content.
    If you don't need to choose the folder from which you need to import the files, because you already know these names, then you could use an array and hardcode the names of the paths and loop through them.
    Thank you.

    I am getting Compile error Ambiguous name detected: Insert

  10. #10
    Valued Forum Contributor rollis13's Avatar
    Join Date
    01-26-2012
    Location
    Cordenons
    MS-Off Ver
    Excel 2016 32bit - Win 11
    Posts
    915

    Re: Open directory for multiple times to import photos

    You have duplicated the Function insert(PicPath, counter) in your project.
    Last edited by rollis13; 03-04-2022 at 07:11 AM.

  11. #11
    Registered User
    Join Date
    03-02-2022
    Location
    Gemany
    MS-Off Ver
    365
    Posts
    13

    Smile Re: Open directory for multiple times to import photos

    dangelor any updates please ?

  12. #12
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Open directory for multiple times to import photos

    Not sure what you're asking of me...

    The unlike the file picker, the folder picker will only allow you to choose one folder. Could you create a simple for/next to call the procedure 3 times?

  13. #13
    Registered User
    Join Date
    03-02-2022
    Location
    Gemany
    MS-Off Ver
    365
    Posts
    13

    Re: Open directory for multiple times to import photos

    Quote Originally Posted by dangelor View Post
    Not sure what you're asking of me...

    The unlike the file picker, the folder picker will only allow you to choose one folder. Could you create a simple for/next to call the procedure 3 times?
    yeah it is okay to run the code for another time and not have a selected range to place the photos in as long as I can sort them below each other with difference of 50 rows every time I run the code,

    The first time the photos will be placed in rows 50, 100, 150, 200.

    The next run I want the photos to be placed in 250, 300, 350, 400

    how to do so please

  14. #14
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Open directory for multiple times to import photos

    Since the variable counter is never reset, start the loop just before the folder picker and end it just before the end of the sub.

  15. #15
    Registered User
    Join Date
    03-02-2022
    Location
    Gemany
    MS-Off Ver
    365
    Posts
    13

    Re: Open directory for multiple times to import photos

    Quote Originally Posted by dangelor View Post
    Since the variable counter is never reset, start the loop just before the folder picker and end it just before the end of the sub.
    could you please help me more, I am still new to VBA

  16. #16
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Open directory for multiple times to import photos

    Possibly...
    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    03-02-2022
    Location
    Gemany
    MS-Off Ver
    365
    Posts
    13

    Re: Open directory for multiple times to import photos

    Quote Originally Posted by dangelor View Post
    possibly...
    Please Login or Register  to view this content.
    worked superrrr
    thank you alot

  18. #18
    Registered User
    Join Date
    03-02-2022
    Location
    Gemany
    MS-Off Ver
    365
    Posts
    13

    Re: Open directory for multiple times to import photos

    Quote Originally Posted by dangelor View Post
    Possibly...
    Please Login or Register  to view this content.
    I have one more question please.
    If i=3, then I decided to add photos from 2 folders only .. I click cancel when the dialog opens for the third time ... here the photos from folder 2 are being re-added.
    The function is continuing to work even when clicking cancel.
    What would be a possible solution.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Import Coordinated from excel to Photos
    By rajatds31 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-30-2021, 03:41 AM
  2. Import some data and files+photos from website (with subpages) to excel
    By Matte0s in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-26-2021, 03:16 PM
  3. Replies: 6
    Last Post: 07-19-2014, 07:17 AM
  4. Replies: 2
    Last Post: 02-14-2014, 02:23 PM
  5. Auto Import Photos From Specified Directories
    By jwbglobal in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-15-2013, 12:30 PM
  6. [SOLVED] Import multiple files from same directory
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-18-2013, 03:56 AM
  7. import text files multiple from parent directory
    By Craig.Selby in forum Excel General
    Replies: 2
    Last Post: 07-11-2012, 11:41 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1