Solved

Opening a folder using VBA

Posted on 2011-09-26
3
242 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

733 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