?
Solved

Opening a folder using VBA

Posted on 2011-09-26
3
Medium Priority
?
250 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 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

649 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