Created
July 19, 2025 19:27
-
-
Save SHi-ON/2e186b99e2da1c78b6c91f109f92c97a to your computer and use it in GitHub Desktop.
Shell function for macOS to save all open Microsoft Excel workbooks and quit the application safely from the terminal.
This file contains hidden or 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
# quitExcel.sh | |
# | |
# Function: quitExcel | |
# | |
# Description: | |
# Saves all open workbooks in Microsoft Excel and then quits the application, | |
# using AppleScript. Useful for closing Excel from the terminal and ensuring | |
# all data is saved. | |
# | |
# Usage: | |
# - Copy this function to your ~/.zshrc or ~/.bashrc | |
# - Source your shell config: source ~/.zshrc | |
# - Run `quitExcel` from the terminal | |
quitExcel() { | |
# Save all open workbooks in Microsoft Excel | |
osascript -e 'tell application "Microsoft Excel" to save every workbook' | |
# Quit Microsoft Excel | |
osascript -e 'tell application "Microsoft Excel" to quit' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment