opening excel document with shell as read only

H

Hcoms

Hello,

I am presently using access to open an excel file by using the shell
command. Is it possible by some command e.g. \readonly to open the excel
file as read only?

Cheers
 
D

Dave Peterson

If you're automating excel from another program, you may be able to just create
an instance of excel and open your workbook readonly:

This worked for me from MSWord:

Option Explicit
Sub testme()

Dim myXL As Object

On Error Resume Next
Set myXL = GetObject(, "Excel.Application")
If Err.Number = 429 Then
Set myXL = CreateObject("Excel.Application")
End If
On Error GoTo 0

myXL.Visible = True

myXL.Workbooks.Open FileName:="C:\my documents\excel\book1.xls", _
ReadOnly:=True

Set myXL = Nothing

End Sub

=====
If you're running something that doesn't support this kind of automation, this
worked for me:

Shell "excel /r ""C:\my documents\excel\book1.xls"""

I didn't need the full path to excel, but you may want to test that closely.

And you can read about startup switches in excel (/r in this case) in Excel's
help.

Search for "Customize how Excel starts"
 
Top