Open a folder with Explorer.exe usintg VBA?

H

Henro

Can I open a folder in explorer.exe using VBA (ACC2000)

The path should be a variable (which I already declared)

What is the right command?

Grtz Henro
 
D

Danny J. Lesandrini

What do you want to do with the folder?

If you just want Windows to open it, you can use this ...

shell "explorer.exe C:\TruStileDB"

If you want to loop through the files, then you can use
the File Scripting Object to ennumerate and work with
all the files of a folder. For that code, look here ...

http://www.w3schools.com/asp/asp_ref_folder.asp
 
H

Henro

I use the following code to make a folder.
I want to open that same folder using explorer.exe so your shell comand does
a lot of good.
I only need to find out how I can get Exoplorer.exe to open the folder that
is defined in

Dim folder As String

folder = DLookup("SysteemInstellingen.Opslagfolder",
"SysteemInstellingen") & Me.Clientnaam



Another question: SysteemInstellingen.Opslagfolder is a pathname that is
given in by a user. If I use the code as below I get a folder with the name

D:\Clienten\2004Clientnaam

I would like to have a backslash between D:\Clienten\2004 and Clientnaam (as
in: D:\Clienten\2004\Clientnaam)
Is that possible? If yes then how?

Tia Henro

Below the code used to create the folder.

Private Sub DirMaken_Click()
Dim fso
Dim folder As String

folder = DLookup("SysteemInstellingen.Opslagfolder", "SysteemInstellingen")
& Me.Clientnaam

Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(folder) Then
fso.CreateFolder (folder)
Else
MsgBox folder & " bestaat al!", vbExclamation, "Map reeds aanwezig"
End If
End Sub
 
V

Van T. Dinh

Try

folder = DLookup("SysteemInstellingen.Opslagfolder", _
"SysteemInstellingen") & "/" & Me.Clientnaam

Just in case there are spaces in the path, you should
enclose the path in double-quotes like:

Shell "explorer.exe """ & folder & """"

BTW, Danny's posted code is an example of the Shell method
*only* since we don't know exactly your set-up. It is *up
to you* to modify the code to suit your set-up using
Access Help. If you still can't work out how to adapt the
code, post follow-up question in the same thread. There
is no needs to say that someone's advice "does a lot of
good".

HTH
Van T. Dinh
MVP (Access)


-----Original Message-----
I use the following code to make a folder.
I want to open that same folder using explorer.exe so your shell comand does
a lot of good.
I only need to find out how I can get Exoplorer.exe to open the folder that
is defined in

Dim folder As String

folder = DLookup("SysteemInstellingen.Opslagfolder",
"SysteemInstellingen") & Me.Clientnaam



Another question: SysteemInstellingen.Opslagfolder is a pathname that is
given in by a user. If I use the code as below I get a folder with the name

D:\Clienten\2004Clientnaam

I would like to have a backslash between D:\Clienten\2004 and Clientnaam (as
in: D:\Clienten\2004\Clientnaam)
Is that possible? If yes then how?

Tia Henro

Below the code used to create the folder.

Private Sub DirMaken_Click()
Dim fso
Dim folder As String

folder = DLookup
("SysteemInstellingen.Opslagfolder", "SysteemInstellingen")
 
H

Henro

`Thanks for your tip and I didn't mean it ironicly or somethimg like that, I
actually DID use the shell code in several places en am happy with it! Like
I am with your suggestion.

Grtz Henro
 

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

Top