View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default detect if file opens read-only

Workbook has a readonly property. For example

sFile = "C:\myTest\Volker1.xls"
On Error GoTo file_error
Workbooks.Open Filename:=sFile
If ActiveWorkbook.ReadOnly = True Then


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mal Stone" wrote in message
...
I want to step through all of the files in a directory, update them, and
save. If a file is open (another user), the code can assign a new name and
saveAs. How can I tell if it opens as readonly?
Multiuserediting property doesn't work, this is not a shared list.
The following doesn't work, it puts up a dialog asking the user whether to
replace:

On Error Resume Next
ActiveWorkbook.Save
If Err.Number = 1004 Then
strPathFile = Left(strPathFile, Len(strPathFile) - 4)
strPathFile = strPathFile & "XXX.xls"
ActiveWorkbook.SaveAs Filename:=strPathFile
Err.Clear
End If
It doesn't get past the .save step.
I want this to run without user interaction.
Thanks for any suggestions