+ Reply to Thread
Results 1 to 4 of 4

How to active a folder that is already opened using VBA?

  1. #1
    Registered User
    Join Date
    12-30-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    20

    How to active a folder that is already opened using VBA?

    I want to open a specific folder say -
    Shell "explorer.exe " & "N:\Common_Operational\Investigation Report\", vbNormalFocus
    But if this folder is previously opened, then do not reopen the folder but just display the opened folder to the user.
    Can anyone help me to do this?

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to active a folder that is already opened using VBA?

    Something like this:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-22-2012
    Location
    Land of Oz
    MS-Off Ver
    Excel 2000
    Posts
    30

    Re: How to active a folder that is already opened using VBA?

    JB; I ran your suggested code, and it does open the Windows Explorer file (after I changed Wnd.Name to "Microsoft Internet Explorer"... I have no idea why, but that's the name Microsoft Windows XP uses for Windows Explorer). However, I can't get it to recognize the Folder if it is already open. I believe this is because the Wnd.Document.Folder.Self.Path is not a string, i.e. no quotes, while strFolder is a string. Is there a way I can change the value of Wnd.Document.Folder.Self.Path to a string? Thanx.

    LonesomeJoe

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to active a folder that is already opened using VBA?

    Wnd.Document.Folder.Self.Path is a string.

    File Explorer and Windows Explorer are the Windows objects that use the Self.Path for local directory listings. If you're using Internet Explorer instead of File Explorer, that won't work. I don't have first hand practice detecting the URLs currently displayed in a browser, but it's probably not rocket science.

    Perhaps: http://msdn.microsoft.com/en-us/library/ms970456.aspx
    ..check out using the LocationURL... that looks promising.

+ 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. VBA: Save workbook in same folder where it is opened.
    By sroysroy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-09-2013, 11:51 PM
  2. UserForm stays active when print preview is opened
    By brandonduginski in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-17-2013, 01:03 AM
  3. [SOLVED] VBA Code open files in folder, copy text to workbook-Next time folder opened copy only new
    By Bikeman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-02-2013, 07:59 PM
  4. Same Folder as the sheet i opened
    By unlink in forum Excel General
    Replies: 0
    Last Post: 01-04-2011, 03:20 AM
  5. Excel 2007 : make Sheet1 active when file is opened
    By JennaL in forum Excel General
    Replies: 2
    Last Post: 05-06-2010, 10:41 PM

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