Save Word/Excel/PPT file without changing last modified (date/user)

Hi, we are evaluating Aspose libraries for integration into a cloud solution. Our goal is to download MS Office files from the cloud and set some custom properties into the files before sending them to the downloading user. The question right now is, if it’s possible to add custom properties to e.g. an Excel file and save it without changing the last modified date/user. Can you answer this? Thanks in advance.

@Bodo_Wetzel,

Your query has two parts:

  1. Setting customer properties.
  2. Saving document without changing last modified user or date information.

Answer to 1:
Yes, you can add custom properties to Word, Excel and Power point documents. For details, please visit the link:

Answer to 2:
In case of MS Power Point document, support for preserving the the last modified date/time and user information on adding or changing custom document property is available. We have logged a request for this feature into our system with ID SLIDESNET-40262. We will update you here once there is some information or a fix version available in this regard.

In case of MS Excel document, Aspose.Cells exposes two properties to store the user and date information of last modification. These properties can be used to read and set the values.

  • LastSavedBy
  • LastSavedTime

You can set your desired last modified Date/Time and saved by information before saving the Excel file. Sample code snippet is given below:

CODE:

        Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook("sample-document-properties.xlsx");
        Aspose.Cells.Properties.BuiltInDocumentPropertyCollection docproperties = workbook.Worksheets.BuiltInDocumentProperties;
        docproperties.LastSavedBy = ".......";
        docproperties.LastSavedTime = DateTime.Now;

Hope the above information helps. Feel free to contact us in case of any query or comments.

@Bodo_Wetzel,

For following request concerning to Aspose.Slides, I suggest you to please try using below sample code.

string sourcePath = path + "source.pptx";
string destPath = path + "dest.pptx";

Presentation presentation = new Presentation(sourcePath);
var tempLastSavedTime = presentation.DocumentProperties.LastSavedTime; // preserving source presentation LastSavedTime 

// Presentation editing and saving
presentation.Slides.RemoveAt(0); // for example remove slide
presentation.Save(destPath, SaveFormat.Pptx);

// Read and correct saved presentation properties
IPresentationInfo pInfo = PresentationFactory.Instance.GetPresentationInfo(destPath);

IDocumentProperties docProps = pInfo.ReadDocumentProperties();
docProps.LastSavedTime = tempLastSavedTime; // restore source LastSavedTime value
docProps.LastSavedBy = "Changed"; // change LastSavedBy user name 

pInfo.UpdateDocumentProperties(docProps);
pInfo.WriteBindedPresentation(destPath);

source.pptx.zip (40.0 KB)
dest.pptx.zip (34.0 KB)

The issues you have found earlier (filed as SLIDESNET-40262) have been fixed in this update.