LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default How could I default an excel file to be openned as READ ONLY once it is saved under a name?

George,
You are welcome.
Jim Cone


"George" wrote in message oups.com...
Dear Jim:
It is perfect. Whenever you stop by Houston, please let me know and I
will buy you a meal. My e-mail is .
Thanks again and have a great day!
George


Jim Cone wrote:
George,
Well, try this version.
--
Jim Cone
San Francisco, USA
http://www.officeletter.com/blink/specialsort.html

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
On Error GoTo BadSave
Dim strCurrentName As String
Dim strNewName As Variant
Dim lngPos As Long

strCurrentName = Me.Name
StartOver:
strNewName = Application.GetSaveAsFilename(, "Workbook (*.xls),*.xls")
If strNewName = False Then
Cancel = True
Exit Sub
Else
lngPos = InStrRev(strNewName, Application.PathSeparator, -1, vbTextCompare)
strNewName = Mid$(strNewName, lngPos + 1, 999)
If StrComp(strNewName, strCurrentName, vbTextCompare) < 0 Then
Application.EnableEvents = False
Me.SaveAs strNewName, xlNormal
Application.EnableEvents = True
Cancel = True
Else
MsgBox "Please use a new name for the file. ", vbExclamation, "Save As"
GoTo StartOver
End If
End If
Exit Sub

BadSave:
Beep
Cancel = True
Application.EnableEvents = True
End Sub
'---------------


"George"
wrote in message
Hi, Jim:
Thank you so much for all your time and efforts. It looks very good.
However, we need one more step to get it done. That is, whenever I am
trying to save the file, it will ask me "The file already exists. Do
you want to replace the existing file?". If I choose "No", everything
is perfect. But I DO NOT like people to choose "Yes". In other words, I
DO NOT want people to replace any exisiting file. Whenever they modify
a file, they MUST save it under a different name. There is no
exceptions.
Thanks again,
George


 
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
XL File on DeskTop cannot be openned helmekki[_105_] Excel Programming 2 November 19th 05 06:09 PM
Excel file opened as read-only, if saved by another user GeEf Excel Discussion (Misc queries) 2 August 28th 05 04:29 PM
How to get an excel doc not saved as "Read Only" bunbarn Excel Discussion (Misc queries) 2 August 19th 05 12:32 AM
Read only error messagfe on file that was previously saved and ope Firemedic395 Excel Discussion (Misc queries) 1 December 8th 04 04:07 PM
Excel sheets saved as XML files that can be read by .NET nabil Elibiary Excel Programming 1 December 8th 03 08:40 AM


All times are GMT +1. The time now is 04:52 AM.

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"