Open a folder in VBA

aryan_hr

Board Regular
Joined
Feb 19, 2002
Messages
222
Hi,
It is my program that opens a folder " My_Folder" in VBA.
But if there is an error, windows exploere showes the error not my program. why??
best wishes
-------------------------------------
Private Sub Show_Input()
Dim My_Folder As String
My_Folder = "A:ddd"
On Error GoTo Error_Show_Input:

Shell "c:windowsexplorer " + My_Folder, 1
On Error GoTo 0
Exit Sub
Error_Show_Input:
MsgBox "Progran can not open this folder." + Chr(13) + Chr(10) + "[" + Error(Err) + "]", vbOKOnly, "Error"
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hi aryan_hr,

I'm no expert but I believe that when you 'shell out' to another program, eg explorer, control passes to that program. Therefore, your error-trapping routine will not catch any errors arising in explorer.

What exactly are you trying to achieve? Could it be done with "Application.GetOpenFilename"? Or try the following link for bringing-up an open folder dialog box in VBA:

http://www.erlandsendata.no/english/vba/folders/selectfolder.htm

HTH
 
Upvote 0
Hi Richie,
thanks, you are right about error-trapping routine.
But I exactly want to open a folder in VB or VBA.
How can I do it in my program and catch any errors arising ?
Also I did it by "Shell" and before running the "Shell" commend, I checked the folder and trapped the error.
But I think there is a simple way for this work.
any help?
best wishes
 
Upvote 0
Hi,

Did you check the link above? I believe that does what you are looking for?


_________________<font color="blue"> «««<font color="red">¤<font color="blue"><font size=+1>Richie</font><font color="red">¤<font color="blue"> »»»</font>

caffeine_sample.gif
</gif>
This message was edited by Richie(UK) on 2002-09-23 03:50
 
Upvote 0
Hi,
yeah... I had seen it before. That program only selects a folder and not open it.
I only want to open a folder.
any help?
 
Upvote 0
Hi,

What are you trying to achieve?

That is, what are you going to do once you have opened the folder? Are you saving, loading, listing or what?
 
Upvote 0
Hi,
thanks for your reply.
I have written a program that creates a new folder including some files. Now after finishing my program, I want to open this folder and take a look in.
any help?
 
Upvote 0
Hi,

How about using "Dir" or "FileSearch" to provide the information that you want?

Or, possibly, "Application.GetOpenFileName" if you really want a browser type view.

HTH
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,592
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top