Open windows explorer to specific folder according to user text

G

Guest

I would like to open Windows Explorer to a specific folder according to the
data a user enters.

The main path will always be the same (Ex. S:\Fire Dept\Accident Reports).
The part that changes is the Case # which is a subfolder under the example
main path. This Case # data is collected via a combo or text box.

The user just enters a Case # into the field, then clicks a button - and is
taken to the folder within Windows Explorer (Ex. S:\Fire Dept\Accident
Reports\060325-568).

Windows Explorer may or may not already be open.

As always - thank you for you help.

Access 97 and 2000

Seth
 
G

Guest

I only want to open Windows Explorer to a particular folder - defined by a
concatenated string. No opening of files is needed.

For example - to open Windows Explorer to a specific folder, using an icon,
the Target field equals - %SystemRoot%\explorer.exe /e, R:\CE Stuff

And Windows Explorer opens the R drive to the CE Stuff folder, allowing me
to see all the contents of the CE Stuff folder.

Seth
 
D

Douglas J. Steele

Try:

Shell "explorer.exe /e, ""R:\CE Stuff""", vbNormalFocus

(that's 2 double quote in front of the folder name, and 3 after it)
 
G

Guest

How so I accomplish this using a variable so I can concatenate the full path?

Like follows:

Dim strString As String
strString = "F:\Jobs\" & Me!Text1
Shell "explorer.exe / e, ""strString""", vbNormalFocus

Thank you for your help.

Seth
 
D

Douglas J. Steele

Dim strString As String
strString = "F:\Jobs\" & Me!Text1
Shell "explorer.exe / e, """ & strString & """", vbNormalFocus

This time, it's 3 double quotes before, 4 after.
 
G

Guest

Thank you Doug.

So what are all the quotes about and where can I go to read about why they
are necessary?

Seth
 
D

Douglas J. Steele

If you were typing in the Run box, you'd put something like:

explorer.exe /e, "R:\CE Stuff"

To store that in a variable, you'd put quotes around it. However, to
represent a quote inside a quoted string, you need to double it. To store

He said "Stop" before he left.

you'd use

strX = "He said ""Stop"" before he left."

Therefore, to store the line at the top, you need

strX = "explorer.exe /e, ""R:\CE Stuff"""

When you're trying to incorporate the variable, you need to ensure that
what's in front of the variable ends in a double quote (hence the 3 quotes
before) and has a double quote afterwards (hence the 4 quotes: you start and
end with a quote, and you put two double quotes inside to represent the
single double quote you want):

strX = "explorer.exe / e, """ & strString & """"

Alternatively, you could take advantage of the fact that Chr$(34) is the
representation for a double quote, and use

strX = "explorer.exe / e, " & Chr$(34) & strString & Chr$(34)
 

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