Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to impose Expire Date on MS Office files? [modified]

How to impose Expire Date on MS Office files? [modified]

Scheduled Pinned Locked Moved C#
tutorialcsharpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sachinkalse
    wrote on last edited by
    #1

    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

    R 1 Reply Last reply
    0
    • S sachinkalse

      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

      R Offline
      R Offline
      Russell Jones
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • R Russell Jones

        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

        S Offline
        S Offline
        sachinkalse
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups