We help IT Professionals succeed at work.

Can you prevent user from deleting a file when using msoFileDialogOpen?

In VBA macros, I frequently use
Application.FileDialog(msoFileDialogOpen)

Open in new window

to prompt the user to select a file from a specific folder.  

Is there a way to prevent them from deleting a file (accidentally or intentionally) while searching for one to open?

Thanks
Comment
Watch Question

Bryce BassettFreelance VBA programmer

Author

Commented:
Piggybacking on my own question.  I also don't want the user to be able to navigate to any other folders.  Bottom line, I want to limit them to "read only" access to the folder I choose.

If the answer is I need to create my own dialog listing files in the target folder, rather than use the built in File Open dialog, I could do that.  But I prefer the simplest approach.

Thanks again.
strivoliIT Manager
CERTIFIED EXPERT

Commented:
Did you consider setting the File System Permissions?
Consulting
CERTIFIED EXPERT
Distinguished Expert 2017
Commented:
I'm afraid that the standard file dialog box does not have the kind of behavior you want, and VBA offer no way to control it.
Bryce BassettFreelance VBA programmer

Author

Commented:
Thanks, I suspected the answer was no I don't have such control when using the standard dialog.  This is an enterprise-wise application, so it would not be possible for me to control permissions.  Thanks, both.