ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Default to Read Only (https://www.excelbanter.com/excel-programming/331937-default-read-only.html)

KNg

Default to Read Only
 
Hi,

Please shed me light on the macro syntax to default the OpenFile option to
'Read Only' when a dialog box is prompted for password-protected file.

Thanks,
Kenny.



keepITcool

Default to Read Only
 
Kenny

avoid the FileFind Dialog: you'll have no control

use GetOpenFileName to get the user to tell you which file he wants.
then have your code do it with all the verifications etc that you want..
in this case few.. just the Readonly


Sub OpenRO()
Dim vFile As Variant
vFile = Application.GetOpenFilename("Excel Files,*.xls")
If vFile = False Then
Beep
Else
Workbooks.Open vFile, ReadOnly:=True
End If

End Sub


see VBA help for the methods..


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


KNg wrote :

Hi,

Please shed me light on the macro syntax to default the OpenFile
option to 'Read Only' when a dialog box is prompted for
password-protected file.

Thanks,
Kenny.



All times are GMT +1. The time now is 12:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com