Solved

Opening a folder using VBA

Posted on 2011-09-26
3
243 Views
Last Modified: 2012-08-13
Option Explicit


Sub TextBox2_Click()

    Dim fso
    Dim fol As String
    
    fol = "C:\GL Summary" ' change to match the folder path
    Set fso = CreateObject("Scripting.FileSystemObject")
    If Not fso.FolderExists(fol) Then
        fso.CreateFolder (fol)

        If MsgBox("Folder created! Do you want to open the folder to move your files?", vbYesNo + vbInformation, "Open Excel Folder") = vbYes Then Shell Environ("windir") & "\explorer.exe " & Application.CurrentProject.Path & "C:\GL Summary\", vbNormalFocus
 
    Else
        MsgBox fol & " already exists!", vbExclamation, "Folder Exists!"
    End If
End Sub

Open in new window


Hi all,

I am trying to open the above folder via VBA using a 'Yes/No' message. However I am getting an 'object doesn't support this property or method error' in this part 'Shell Environ("windir") & "\explorer.exe '

Any help is much appreciated!
0
Comment
Question by:Shanan212
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 26

Accepted Solution

by:
redmondb earned 500 total points
ID: 36600756
Hi, Shanan212.

Please remove "& Application.CurrentProject.Path" so the line is...

 
If MsgBox("Folder created! Do you want to open the folder to move your files?", vbYesNo + vbInformation, "Open Excel Folder") = vbYes Then Shell Environ("windir") & "\explorer.exe " & "C:\GL Summary\", vbNormalFocus

Open in new window


Regards,
Brian.
0
 
LVL 13

Author Closing Comment

by:Shanan212
ID: 36600790
Much appreciated!
0
 
LVL 26

Expert Comment

by:redmondb
ID: 36600817
Short and sweet, many thanks!
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question