Link to home
Start Free TrialLog in
Avatar of pfjvisser
pfjvisser

asked on

SHELL TO OPEN A FOLDER

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..
Avatar of rspahitz
rspahitz
Flag of United States of America image

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
Avatar of pfjvisser
pfjvisser

ASKER

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

Gr,
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

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.
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.
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
ASKER CERTIFIED SOLUTION
Avatar of vinnyd79
vinnyd79

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Richie_Simonetti
IMHO, there is no way you could "filter" an Explorer window.
You have to do it by yourself (code from rspahitz could help).
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"


Thanks all. I had solved the prob with the coding from
vinnyd79. SO thanks to al of you folks..