Open a Folder

  • Thread starter Thread starter danpt
  • Start date Start date
D

danpt

I backup different xls file groups in J:\Backup\aBackup, J:\Backup\bBackup
and so on.
Please help me to scripte a vba that will open the bBackup folder.
Thanks
 
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Echo WshShell.CurrentDirectory
WshShell.CurrentDirectory = "J:\Backup\bBackup"
 
Hi, Marvin
It is not quite working.
WScript needs to be defined.
I don't know how. Please take a look again.
Thanks
 
Hi, Steve
I just want to open an Explorer type window to reveal the contents of the
bBackup folder.
 
If you just want to review the contents of a folder, you could use
application.getopenfilename or application.getsaveasfilename
 
As long as you don't want your code to interact with Windows Explorer, you
should be able to open it using this...

Shell "explorer.exe", vbNormalFocus
 
Thank you very much, Rick
Shell "explorer.exe J:\Backup\bBackup", vbNormalFocus
which is what I wanted.
 
Hi Dave,
It opens to dialog window "Documents".
How about "J:\Backup\bBackup" instead.
 
Dim myPath As String
Dim SavedPath As String

SavedPath = CurDir
myPath = "J:\Backup\bBackup"

ChDrive myPath
ChDir myPath

Application.GetOpenFilename

ChDrive SavedPath
ChDir SavedPath
 
Thank you very much, Dave
I learn something new

Dave Peterson said:
Dim myPath As String
Dim SavedPath As String

SavedPath = CurDir
myPath = "J:\Backup\bBackup"

ChDrive myPath
ChDir myPath

Application.GetOpenFilename

ChDrive SavedPath
ChDir SavedPath
 
Hello
What if you wanted to make J:\Backup\Backup a user defined location, say it
is defined by a value in a cell of a spreadsheet:
Exa - cell B3 = "J:\Backup\Backup "

I tried
mypath=cell(3,2)
Shell "explorer.exe mypath", vbNormalFocus

it says mypath is not a directory

thanks a bunch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top