Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SHELL TO OPEN A FOLDER

Posted on 2002-07-16
10
Medium Priority
?
248 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
  • 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
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!

 

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 150 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

782 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