megha
09-17-2010, 10:53 AM
I have a VBA code in exel that has command button to “ SAVE AS” file at the different location. The macro works fine. The only thing I would like to add is the “protection.” Some kind of protection so that the saved file cannot be editable. I don’t want to use any kind of password. I also don’t want to use read-only command as it does not work. Is there any other code or option? I have copy the code I’m using right now.
Private Sub CommandButton1_Click()
Dim sFileName As String
Dim sPath As String
If Range("C3").Value = " " Then
MsgBox "Please Select Your Name", vbCritical
ElseIf Range("G3").Value = " " Then
MsgBox "Please Select Date", vbCritical
ElseIf Range("J3").Value = " " Then
MsgBox "Please Select Shift", vbCritical
Else
CommandButton1.Visible = False
sFileName = Range("N1").Value
sFileName = sFileName & ".xls"
sPath = "http://"
ActiveWorkbook.SaveAs Filename:=sPath & sFileName, FileFormat:=xlNormal, ReadOnlyRecommended:=False
ThisWorkbook.Close SaveChanges:=False
End If
End Sub
Private Sub CommandButton1_Click()
Dim sFileName As String
Dim sPath As String
If Range("C3").Value = " " Then
MsgBox "Please Select Your Name", vbCritical
ElseIf Range("G3").Value = " " Then
MsgBox "Please Select Date", vbCritical
ElseIf Range("J3").Value = " " Then
MsgBox "Please Select Shift", vbCritical
Else
CommandButton1.Visible = False
sFileName = Range("N1").Value
sFileName = sFileName & ".xls"
sPath = "http://"
ActiveWorkbook.SaveAs Filename:=sPath & sFileName, FileFormat:=xlNormal, ReadOnlyRecommended:=False
ThisWorkbook.Close SaveChanges:=False
End If
End Sub