Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default detect if file opens read-only

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default detect if file opens read-only

if ActiveWorkbook.Readonly = True then
' the workbook is opened readonly

End if

--
Regards,
Tom Ogilvy

"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




  #3   Report Post  
Posted to microsoft.public.excel.programming
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel file opens Read-Only for different users...stop! Pradhan Excel Discussion (Misc queries) 1 November 3rd 08 06:12 PM
.xlsx file opens as read-only Michelle Excel Discussion (Misc queries) 1 April 30th 08 05:51 PM
Linked file always opens as read-only Brian999 Excel Discussion (Misc queries) 3 August 15th 06 06:33 PM
Read only file opens Bobby Excel Discussion (Misc queries) 0 January 30th 06 02:29 PM
Hyperlink in Excel opens the right program, but can't read file. Katydid Excel Discussion (Misc queries) 0 May 6th 05 04:16 PM


All times are GMT +1. The time now is 03:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"