Open Folder Dialog box with Read-Only option

QuantBurner

New Member
Joined
Jan 29, 2011
Messages
42
Hi,
I need some VBA code that opens a folder just as if the folder icon is clicked on in Excel (ie. I want a dialogue box open to a folder where the user selects a file and can open as the file as read-only). I found code that will give me a open folder box but not with the read-only option (eg using something like ActiveWorkbook.FollowHyperlink Address:=.[C5], NewWindow:=True). Hope that makes sense.

Thanks!
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Maybe something like this. It returns the path to the folder as a string

Code:
With Application.FileDialog(msoFileDialogFolderPicker)
    .AllowMultiSelect = False
    .Show
    MyFolder = .SelectedItems(1)
End With

(Excel 2002 and later)
 
Upvote 0
Thanks but, alas, that didn't work for me. I'm after a way to open the normal "open file" folder window that allows you to open a file as "Open", "read-only", "copy" or " open and repair" by clicking on the down arrow to the right of the "open" button in the lower right corner of the Open dialog box.
Thanks in advance for any help
 
Upvote 0
Maybe like this

Code:
Sub GetFileName()
Dim fName As Variant
fName = Application.GetOpenFilename(FileFilter:="Excel Files (*.XLS), *.XLS", Title:="Select File To Be Opened")
If fName = False Then Exit Sub
Workbooks.Open Filename:=fName, ReadOnly:=True
End Sub
 
Upvote 0
That would only open the file as read-only. I see I could have the user set a variable to read-only or normal. I was hopping for some simple code that would just give me the usual open dialog box like when you click on the open folder icon in Excel, Word, etc.
What I'm wanting is to have a string (eg a path like c:\myfiles\myexcelfile) in a cell that the user can double-click on to open the folder. The user can then select a file in the folder and open it as read-only or normal. I have the double click code working for files (I have a macro that puts a check box next to cells that contains a string (valid path and filename). A check indicates read-only. So, when a user double-clicks on the file, it opens as either read-only or normal depending on whether the check box is clicked). I'm now wanting something similar for folders. Does this make sense?
Thanks!
 
Upvote 0
Finally found what I need:

dim strFolderName as String
strFolderName="C:\myfolders\myExcelfolder\"
ChDir strFolderName
Application.Dialogs(xlDialogOpen).Show

:)
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,681
Members
452,937
Latest member
Bhg1984

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