Solved

SHELL TO OPEN A FOLDER

Posted on 2002-07-16
10
220 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

770 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