PDA

View Full Version : Save a copy of an excel file as Read Only



cchristner
09-05-2016, 07:53 PM
Hey guys,

I was wondering if anyone would be able to help me out. I need a code that will save a copy of an Excel file as a part number that is in the B1 field. With a date stamp and make the copy read only. I was wondering if anyone had any idea's. Basically I want to be able to look back at the data and I will need to know the part number which changes. But the part number is located in the file B1. Than I want to know the date and time it was saved. I also want to view the data at a later date without the option for operators to change the information. An example of the format would be Part_yyyy_mm_dd hh. If anyone could help i would really appreciate it.

cchristner
09-05-2016, 08:25 PM
Also I have a folder named data on my desktop that will hold all the saved read only files.

cchristner
09-06-2016, 12:04 AM
This is what I have so far. It saves a copy with the part number and date stamp but I am still trying to get it set as a read only.

Sub SaveTest()
Dim Path As String
Dim FileName1 As String
Dim DateTime As String
Path = "C:\Users\cory.christner\Desktop\Data\"
FileName1 = Range("B1")
DateTime = " (" & Format(Now, "yyyy-mm-dd hhmm") & ").xlsm"
ActiveWorkbook.SaveCopyAs Filename:=Path & FileName1 & "-" & DateTime & ".xlsm"


End Sub

snb
09-06-2016, 04:58 AM
Why don't you save historical date in the workbook itself ?