Thread
:
How could I default an excel file to be openned as READ ONLY once it is saved under a name?
View Single Post
#
5
Posted to microsoft.public.excel.programming
George
external usenet poster
Posts: 62
How could I default an excel file to be openned as READ ONLY once it is saved under a name?
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
Reply With Quote
George
View Public Profile
Find all posts by George