xlDialogOpen arguments

F

frice

I am trying to display the file Open dialog such that when the user selects
the particular file, it is automatically opened as Read-Only. I'm using:

Application.Dialogs.Item(xlDialogOpen).Show Arg1:="Book1.xlsm", Arg3:=True

Arg1 works so that only Book1.xlsm is shown but when I open the file, it is
not opened as read-only. Any ideas of what I'm doing wrong?

Thanks
 
S

sebastienm

xlDialogOpen
---------------
file_text, update_links, read_only, format, prot_pwd, write_res_pwd,
ignore_rorec, file_origin, custom_delimit, add_logical, editable,
file_access, notify_logical, converter

More generally: for all dialogs
-----------------------------------
type Application.Dialogs, then select 'Dialogs' and press F1 to get the
Help. There, click the 'Dialogs' link and finally on that page you have a
"see Built-in Dialog Box Argument Lists." link for all Dialogs.

Option.
 
F

frice

Thanks for the reponse Sebastien. In my app, I need to use xlDialogs. The
list of arguments shows the third argument as "read_only" so I'm assuming the
Arg3:=True should automatically open the file as read-only but setting the
argument to true has no effect. Any other ideas? Thanks
 
S

sebastienm

For me (win2k/xl2k), using
Application.Dialogs(xlDialogOpen).Show arg3:=True
or
Application.Dialogs(xlDialogOpen).Show , , True
or
Application.Dialogs(xlDialogOpen).Show <file_name>, , True

works fine and opens the selected file as read-only.

Now if it doesn't work for you , you may want to look at the
Application.FIleOpen which returns you the chosen file (String), then you
open the file with Workbooks.Open (<chosenFile>, arg_list) where you can set
Read-Only to True.
 
J

Jim Rech

so I'm assuming the Arg3:=True should automatically open the file as
The Args are used to preset dialog options, where they exist. The 'read
only' option check box has not existed since Excel 95.

You're going to have to switch to this to do what you want:

Dim FName As Variant
FName = Application.GetOpenFilename("Excel Files (*.xl*),*.xl*")
If FName <> False Then
Workbooks.Open Filename:=FName, ReadOnly:=True
End If

--
Jim
| Thanks for the reponse Sebastien. In my app, I need to use xlDialogs. The
| list of arguments shows the third argument as "read_only" so I'm assuming
the
| Arg3:=True should automatically open the file as read-only but setting the
| argument to true has no effect. Any other ideas? Thanks
|
| "sebastienm" wrote:
|
| >
| > xlDialogOpen
| > ---------------
| > file_text, update_links, read_only, format, prot_pwd, write_res_pwd,
| > ignore_rorec, file_origin, custom_delimit, add_logical, editable,
| > file_access, notify_logical, converter
| >
| > More generally: for all dialogs
| > -----------------------------------
| > type Application.Dialogs, then select 'Dialogs' and press F1 to get the
| > Help. There, click the 'Dialogs' link and finally on that page you have
a
| > "see Built-in Dialog Box Argument Lists." link for all Dialogs.
| >
| > Option.
| > ---------
| > You can use the other dialog to open files. I personally prefer it:
| > Application.FileDialog(msoFileDialogOpen)
| > Check the help for more details.
| >
| > --
| > Regards,
| > Sébastien
| > <http://www.ondemandanalysis.com>
| >
| >
| > "frice" wrote:
| >
| > > I am trying to display the file Open dialog such that when the user
selects
| > > the particular file, it is automatically opened as Read-Only. I'm
using:
| > >
| > > Application.Dialogs.Item(xlDialogOpen).Show Arg1:="Book1.xlsm",
Arg3:=True
| > >
| > > Arg1 works so that only Book1.xlsm is shown but when I open the file,
it is
| > > not opened as read-only. Any ideas of what I'm doing wrong?
| > >
| > > Thanks
 
F

frice

Thanks Bob for the response. For some reason, that doesn't work in my
application. The file still doesn't open as read-only.
 
F

frice

Thanks for the response, Jim. I guess I figured that the read-only argument
was the same as clicking the down arraow beside the Open button on the Open
dialog and selecting Open as Read-Only. What's also interesting is that I'm
using a MS Press book on Programming Excel 2003 and it specifically uses the
arg3:=True example to open the file as read-only.
 
J

Jon Peltier

The help files for Excel (and all of Office) have gotten continuously worse
since about Office 97; Jim's comment indicates that this topic hasn't been
updated since Excel 95. The help examples are poorly written and do not
often illustrate more than a rehashing of the syntax. When they are more
illustrative, like this example, they are incorrect. This is unfortunate.

- Jon
 
J

Jim Rech

Correction: The xlDialogOpen example showing arg3:=True appears in Excel
That is a riot. It's good to see that, just like the designers and
developers, the help writers do not actually use Excel.

--
Jim
| Correction: The xlDialogOpen example showing arg3:=True appears in Excel
2007
| help at: http://msdn2.microsoft.com/en-us/library/bb236937.aspx
|
| "Jim Rech" wrote:
|
| > >>so I'm assuming the Arg3:=True should automatically open the file as
| > >>read-only
| >
| > The Args are used to preset dialog options, where they exist. The 'read
| > only' option check box has not existed since Excel 95.
| >
| > You're going to have to switch to this to do what you want:
| >
| > Dim FName As Variant
| > FName = Application.GetOpenFilename("Excel Files (*.xl*),*.xl*")
| > If FName <> False Then
| > Workbooks.Open Filename:=FName, ReadOnly:=True
| > End If
| >
| > --
| > Jim
| > | > | Thanks for the reponse Sebastien. In my app, I need to use xlDialogs.
The
| > | list of arguments shows the third argument as "read_only" so I'm
assuming
| > the
| > | Arg3:=True should automatically open the file as read-only but setting
the
| > | argument to true has no effect. Any other ideas? Thanks
| > |
| > | "sebastienm" wrote:
| > |
| > | >
| > | > xlDialogOpen
| > | > ---------------
| > | > file_text, update_links, read_only, format, prot_pwd,
write_res_pwd,
| > | > ignore_rorec, file_origin, custom_delimit, add_logical, editable,
| > | > file_access, notify_logical, converter
| > | >
| > | > More generally: for all dialogs
| > | > -----------------------------------
| > | > type Application.Dialogs, then select 'Dialogs' and press F1 to get
the
| > | > Help. There, click the 'Dialogs' link and finally on that page you
have
| > a
| > | > "see Built-in Dialog Box Argument Lists." link for all Dialogs.
| > | >
| > | > Option.
| > | > ---------
| > | > You can use the other dialog to open files. I personally prefer it:
| > | > Application.FileDialog(msoFileDialogOpen)
| > | > Check the help for more details.
| > | >
| > | > --
| > | > Regards,
| > | > Sébastien
| > | > <http://www.ondemandanalysis.com>
| > | >
| > | >
| > | > "frice" wrote:
| > | >
| > | > > I am trying to display the file Open dialog such that when the
user
| > selects
| > | > > the particular file, it is automatically opened as Read-Only. I'm
| > using:
| > | > >
| > | > > Application.Dialogs.Item(xlDialogOpen).Show Arg1:="Book1.xlsm",
| > Arg3:=True
| > | > >
| > | > > Arg1 works so that only Book1.xlsm is shown but when I open the
file,
| > it is
| > | > > not opened as read-only. Any ideas of what I'm doing wrong?
| > | > >
| > | > > Thanks
| >
| >
| >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top