Created
May 18, 2024 08:02
-
-
Save tueda/99b2b12d01af428798b25ecf85f3b76a to your computer and use it in GitHub Desktop.
#excel #wsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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