Solved

Opening a folder using VBA

Posted on 2011-09-26
3
233 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
  • 2
3 Comments
 
LVL 26

Accepted Solution

by:
redmondb earned 500 total points
Comment Utility
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
Comment Utility
Much appreciated!
0
 
LVL 26

Expert Comment

by:redmondb
Comment Utility
Short and sweet, many thanks!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
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 will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now