How to impose Expire Date on MS Office files? [modified]
-
I am using Document Library in MOSS to store MS Office files to make use of IRM in MOSS. (Web application) I want to impose expire date at document level before uploading to document library such that even if the document is downloaded on client machine, after expiry date, the document should not open. Thus, is there any way to impose expire date on MS office files (excel/word/power point/ infopath) using C#?:^) Please guide. -- modified at 22:21 Wednesday 13th June, 2007 Regards Sachin
-
I am using Document Library in MOSS to store MS Office files to make use of IRM in MOSS. (Web application) I want to impose expire date at document level before uploading to document library such that even if the document is downloaded on client machine, after expiry date, the document should not open. Thus, is there any way to impose expire date on MS office files (excel/word/power point/ infopath) using C#?:^) Please guide. -- modified at 22:21 Wednesday 13th June, 2007 Regards Sachin
i don't know about using c# but i guess you could add a macro to the documents concerned to either delete their own contents or inform the user that the document has expired. I know MS were talking about creating expiring e-mail etc some while ago but i never heard if they implemented it. Russell
-
i don't know about using c# but i guess you could add a macro to the documents concerned to either delete their own contents or inform the user that the document has expired. I know MS were talking about creating expiring e-mail etc some while ago but i never heard if they implemented it. Russell
Maco can be disabled while opening the document, thus will not be useful. We were trying to add permissions to the file ojbetcs directoy using following code but that is giving very generalized exception "Value does not fall within the expected range" Please have a look at the code below ------------------------------------------
using System; using System.Collections.Generic; using System.Text; using Microsoft.Office.Core; using ExcelInterop = Microsoft.Office.Interop.Excel; using Microsoft.Office.Interop.Word; class Program { private void ImposeExpiryDate() { //For Excel ExcelInterop.ApplicationClass excel = new Microsoft.Office.Interop.Excel.ApplicationClass (); ExcelInterop.WorkbookClass workBook = (ExcelInterop.WorkbookClass)excel.Workbooks.Open( "c:\\test.xls", 0, true, 5, "" , "", true, ExcelInterop. XlPlatform .xlWindows, "\t", false, false , 0, true, 1, 0); ExcelInterop.Sheets sheets = workBook.Worksheets; DateTime dtExpirationDate = DateTime.Today.AddDays(2); try { workBook.Permission.Add(@"sachin@abc.com" ,Microsoft.Office.Core.MsoPermission.msoPermissionFullControl, dtExpirationDate); } catch (Exception EX) { // "Value does not fall within the expected range" ??? } //For Word // Microsoft.Office.Interop.Word.ApplicationClass WordApp = // new Microsoft.Office.Interop.Word. ApplicationClass (); // Microsoft.Office.Interop.Word.Document aDoc = // WordApp.Documents.Open(ref fileName, ref missing, // ref readOnly, ref missing, ref missing, ref missing, // ref missing, ref missing, ref missing, ref missing, // ref missing, ref isVisible); // aDoc.Permission.Add // ("sachin@abc.com" , // Microsoft.Office.Core.MsoPermission.msoPermissionFullControl, // dtExpirationDate); } }
Regards Sachin