ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   protecting a csv file (https://www.excelbanter.com/excel-programming/281745-protecting-csv-file.html)

lothario[_46_]

protecting a csv file
 

Hi,

I have used the following VBA code to save selected ("a1:L45") data to
a csv file.

'---------------------------------
Dim Sh As Worksheet
Set Sh = ActiveSheet
Workbooks.Add Template:=xlWBATWorksheet
Sh.Range("a1:L45").Copy Destination:= _
ActiveWorkbook.Worksheets(1).Range("A1")
ActiveWorkbook.SaveAs Filename:="C:\files\vtew\1\uimw_at_" & _
Format(Now, "yyyy_mm_dd_hh_mm_ss") & ".csv", _
FileFormat:=xlCSV
ActiveWorkbook.Close SaveChanges:=False
'---------------------------------

I would like to ensure that after the file is saved,
the attributes of the file are changed such that:

1. It becomes READ-ONLY.
2. It cannot be deleted.

Please show me the VBA code that I can incorporate to the above to
accomplish this.

Thanks,
Luther


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/


GB[_3_]

protecting a csv file
 
"lothario" wrote in message
...

Hi,


I would like to ensure that after the file is saved,
the attributes of the file are changed such that:

1. It becomes READ-ONLY.
2. It cannot be deleted.

Please show me the VBA code that I can incorporate to the above to
accomplish this.

Thanks,
Luther


Does this help?

This example uses the SetAttr statement to set attributes for a file.

SetAttr "TESTFILE", vbHidden ' Set hidden attribute.
SetAttr "TESTFILE", vbHidden + vbReadOnly ' Set hidden and read-only
' attributes.





All times are GMT +1. The time now is 01:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com