+ Reply to Thread
Results 1 to 11 of 11

How to open folder after checking folder not existed?

  1. #1
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    How to open folder after checking folder not existed?

    The VBA below can open folder "Scan":

    Please Login or Register  to view this content.

    How to advise the VBA so that:
    1. If the folder "Scan" is opened, VBA will not open the "Scan" again.
    2. The folder opens at the left top corner of the screen.

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: How to open folder after checking folder not existed?

    If you use the FileSystemObject API, there is a check folder exists (also file exists) method that does what you are looking for.

    https://docs.microsoft.com/en-us/off...mobject-object

    Here's a simple VBA code to open a folder if exists
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    Re: How to open folder after checking folder not existed?

    Hi JieJenn,

    Still not work. The folder Scan is opened even it has already been opened. (i.e. the folder is opened twice).

  4. #4
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: How to open folder after checking folder not existed?

    Do you mean to check if a folder explorer is already opened? If that's what you are asking for, then I don't think VBA can do that, at least not an easy task. Even using Java, C#, or Python, checking if a folder explorer is current opened is not an easy task. Sorry to give you the bad news.

  5. #5
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    Re: How to open folder after checking folder not existed?

    Hi JieJenn,

    How about firstly close the folder Scan by VBA?

    (if there is no currently opened folder Scan then error resume next in VBA, i.e. using your VBA to open folder Scan)

  6. #6
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: How to open folder after checking folder not existed?

    Anything related to Folder Explorer window has to use the Windows System Object API, which VBA is not designed to do. But if you are really desperate, then this StackOverflow post might help. https://stackoverflow.com/questions/...e-open-file-ex

  7. #7
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    Re: How to open folder after checking folder not existed?

    Thanks JieJenn for suggestion.

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: How to open folder after checking folder not existed?

    Hello london7871,

    Here is a VBA macro to check if the folder is open....

    Please Login or Register  to view this content.
    Example
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  9. #9
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    Re: How to open folder after checking folder not existed?

    Hi Leith Ross,

    How to revise your VBA so that
    if the folder is open, there is a message "The folder is opened".
    if the folder is not open, there is a message "Please open folder".

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: How to open folder after checking folder not existed?

    Hello london7871,

    Here is the updated code.

    Macro Code
    Please Login or Register  to view this content.
    Example
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    Re: How to open folder after checking folder not existed?

    Hi Leith Ross,

    I tried to modify your VBA to check whether folder "Scan" is opened (with path "C:\Users\DK-01\Desktop\Scan"),
    the VBA shows "Folder is Open" if folder "Scan" is currently opened; but cannot show "Please Open Folder" if folder "Scan" is not currently opened.
    Please advise.



    Please Login or Register  to view this content.
    Last edited by london7871; 06-10-2019 at 02:10 AM.

+ 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. [SOLVED] Excel VBA code for selecting a folder then search & open specified files in that folder
    By Excelrookie_1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-27-2021, 03:09 AM
  2. [SOLVED] Macro to list and open .xlsm files in folder and sub-folder
    By Howardc1001 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-24-2019, 07:35 PM
  3. Open folder macro opening wrong folder
    By jomili in forum Word Programming / VBA / Macros
    Replies: 5
    Last Post: 08-23-2018, 09:27 AM
  4. [SOLVED] Open newest folder and specific file in the folder
    By timtim91 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2017, 11:55 AM
  5. Open Folder (Prompt User for final folder name in location path)
    By synergeticink in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-21-2014, 03:33 PM
  6. Macros Open folder, copy, paste and close the folder
    By hahahahahahaha in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-10-2013, 05:03 PM
  7. Export Selected mails to corresponding folder existed in system
    By RajanikantM in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 05-26-2012, 07:55 AM

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