這個(gè)批處理主要用于清理Office 2003/2007/2010版本的Excel的XLSTART文件夾內(nèi)的所有文件,請(qǐng)謹(jǐn)慎使用,使用前請(qǐng)安全關(guān)閉所有Excel工作簿并及時(shí)保存未存檔的工作,為保證清理效果,本批處理會(huì)強(qiáng)制關(guān)閉所有Excel程序。
雙擊bat后出現(xiàn)Microsoft Office Excel Recovery complete:-)則表明修復(fù)完成。
問題詳敘:
打開任意Excel文檔,均出現(xiàn)“Microsoft Office Excel 遇到問題需要關(guān)閉。我們對(duì)此引起的不便表示抱歉。您正在處理的信息有可能丟失。Microsoft Office Excel 可以嘗試為您恢復(fù)”。
然后出現(xiàn)“Microsoft Visual Basic 自動(dòng)化(Automation)錯(cuò)誤 發(fā)生意外。”的對(duì)話框,如下圖所示:
關(guān)于Microsoft Office Excel遇到問題需要關(guān)閉的信息倒有點(diǎn)類似于之前遇到的由于Normal.dot損壞導(dǎo)致Word打開出現(xiàn)的對(duì)話框,于是進(jìn)行手動(dòng)的修復(fù)。
批處理代碼:
批處理會(huì)強(qiáng)制結(jié)束未關(guān)閉的Excel運(yùn)行以保證清理效果:
REM
REM COPYRIGHT : Copyright (c) 2013 WangYe. All rights reserved.
REM
REM DESCRIPTION : Clear ALL FILES in Excel XLSTART directory.
REM AUTHOR : WANGYE
REM WEBSITE : http://wangye.org
REM
REM Compatible with Office 2003/2007/2010
REM
REM Last Update : 2013/1/10
REM
@ECHO OFF
:BEGIN
CLS
ECHO Copyright (c) 2013 WangYe. All rights reserved.
ECHO For more information please visit http://wangye.org
ECHO.
ECHO Please wait...
TASKKILL /F /IM EXCEL.EXE>NUL 1>NUL 2>NUL
SETLOCAL EnableDelayedExpansion
FOR /L %%i IN (14,-1,11) DO (
if %%i NEQ 13 (
SET KEY_NAME="HKLM\SOFTWARE\Microsoft\office\%%i.0\Excel\InstallRoot"
FOR /F "tokens=2*" %%A IN ('REG QUERY !KEY_NAME! /v "Path" 2^>NUL ^| FINDSTR "REG_SZ"') DO (
SET ExcelInstallDir=%%B
CALL :EMPTY_DIR "!ExcelInstallDir!\XLSTART">NUL
)
)
)
SET EXCELDIR=\Microsoft\Excel
CALL :EMPTY_DIR "%APPDATA%%EXCELDIR%\XLSTART">NUL
DEL /F /S /A /Q "%APPDATA%%EXCELDIR%">NUL 1>NUL 2>NUL
GOTO :SUCCEEDED
:EMPTY_DIR
ECHO %1
IF EXIST %1 (
DEL /F /S /A /Q %1>NUL 1>NUL 2>NUL
RMDIR /S /Q %1>NUL 1>NUL 2>NUL
)
MKDIR %1>NUL 1>NUL 2>NUL
GOTO :EOF
:SUCCEEDED
ECHO.
ECHO Microsoft Office Excel Recovery complete:-)
ECHO.
PAUSE
:EOF
EXIT