Solved

SHELL TO OPEN A FOLDER

Posted on 2002-07-16
10
227 Views
Last Modified: 2010-05-03
hi there,
Whats to code to open an existing folder.

I want to open app.path & "\distribution"

How to open it and only showing *.zip files..

Thanks..
0
Comment
Question by:pfjvisser
[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
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 22

Expert Comment

by:rspahitz
ID: 7157622
One simple way:

dim strFilename as string

strFilename = dir$(app.path & "\distribution\*.zip")
while strFilename <> vbNullString
  'Pick one of the follow output choices or others

  ' Option to add filename to a list control
  List1.AddItem strFilename

  ' option to display filename in the immediate window
  Debug.print strFilename

  ' option to add filename to a blank textbox
  Text1.text = Text1.text & strFilename & vbCrLf

  strFilename = dir$
wend
0
 

Author Comment

by:pfjvisser
ID: 7157770
Thanks  rspahitz
But i meen to open it in the windows explorer.
I hoop you can give me a sulution..

Gr,
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7157782
Are you talking about the open dialog box?

If you don't have it, add the component (Microsoft Common Dialog Control) to your project.

Set the filter property= "zip files (*.zip)|*.zip|All files (*.*)|*.*"

In code, set the filename property = "app.path & "\distribution\*.zip"

Then launch the window.

In code:

CommonDialog1.Filter = "zip files (*.zip)|*.zip|All files (*.*)|*.*"
CommonDialog1.Filename = "app.path & "\distribution\*.zip"
CommonDialog1.ShowOpen

0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

Author Comment

by:pfjvisser
ID: 7157787
Whel almost.

-"Distributie" = FOLDERNAME TO OPEN IN EXPLORER-
I meen like a shell(app.path & "\distributie\")

Thats when the windows explorer op the path..

Gr.
0
 

Author Comment

by:pfjvisser
ID: 7157813
Whel almost.

-"Distributie" = FOLDERNAME TO OPEN IN EXPLORER-
I meen like a shell(app.path & "\distributie\")

Thats when the windows explorer op the path..

Gr.
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 7158038
you could use this,but I don't know about only showing zip files:

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal _
lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL = 1

Public Sub OpenDirectory(Directory As String)
ShellExecute 0, "Open", Directory, vbNullString, vbNullString, SW_SHOWNORMAL
End Sub

Private Sub Command1_Click()
OpenDirectory (App.Path & "\distribution")
End Sub
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 50 total points
ID: 7158059
actually you can just use it like this without the OpenDirectory Sub:

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal _
lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL = 1

Private Sub Command1_Click()
ShellExecute 0, "Open", App.Path & "\distribution", vbNullString, vbNullString, SW_SHOWNORMAL
End Sub
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7158076
IMHO, there is no way you could "filter" an Explorer window.
You have to do it by yourself (code from rspahitz could help).
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7158122
The old versions of explorer let you filter, but that caused lots of problems because every folder would filter with the same criteria and it caused a lot of confusion if you left and came back later...you'd think that your files were gone.  For example, you filter by *.zip, then look for your Word documents and can't find them.

What you might want to do is simply drop a filelistbox (looks like a piece of paper with a folded corner) on your form and add that filter in the view by changing the Pattern property to "*.zip"  I think you also need to change the "current" directory to the desired directory in code:

CurDir = app.path & "\distribution"


0
 

Author Comment

by:pfjvisser
ID: 7159092
Thanks all. I had solved the prob with the coding from
vinnyd79. SO thanks to al of you folks..
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

734 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