Skip to content

Instantly share code, notes, and snippets.

@tueda
Created May 18, 2024 08:02
Show Gist options
  • Save tueda/99b2b12d01af428798b25ecf85f3b76a to your computer and use it in GitHub Desktop.
Save tueda/99b2b12d01af428798b25ecf85f3b76a to your computer and use it in GitHub Desktop.
#excel #wsh
var args = WScript.Arguments;
if (args.length !== 1) {
WScript.Echo("Please drag and drop an Excel file onto this script.");
WScript.Quit();
}
var filePath = args(0);
try {
var excel = new ActiveXObject("Excel.Application");
excel.Visible = false;
excel.DisplayAlerts = false;
var workbook = excel.Workbooks.Open(filePath);
var properties = workbook.BuiltinDocumentProperties;
properties.Item("Creation Date").Value = properties.Item("Last Save Time").Value;
workbook.Save();
workbook.Close(false);
excel.Quit();
WScript.Echo("OK");
} catch (e) {
WScript.Echo("An error occurred: " + e.message);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment