Solved

SHELL TO OPEN A FOLDER

Posted on 2002-07-16
10
214 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:pfjvisser
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 28

Expert Comment

by:vinnyd79
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks all. I had solved the prob with the coding from
vinnyd79. SO thanks to al of you folks..
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now