如何用vba禁用excel自动恢复 如何用VBA关闭指定的电子表格,同时也进行保存?
excel\u7981\u7528 vba\u5728Excel\u9009\u9879\u7684\u5b8f\u5b89\u5168\u6027\u8bbe\u7f6e\u91cc\u9762\uff0c\u7981\u7528\u5373\u53ef
Workbooks("book1").Close True
\u5173\u95ed\u5e76\u4e14\u4fdd\u5b58\u540d\u79f0\u4e3a book1 \u7684\u5de5\u4f5c\u7c3f
Workbooks("book1").Close False
\u5173\u95ed\u5e76\u4e14\u4e0d\u4fdd\u5b58\u540d\u79f0\u4e3a book1 \u7684\u5de5\u4f5c\u7c3f
1. 全局禁用(作用于所有工作簿):
Application.AutoRecover.Enabled = False
对应【Excel 选项】
取消勾选【保存工作簿】中的【保存自动恢复信息时间间隔】复选框:
2. 局部禁用(作用于此工作簿,若要禁用其他工作簿请替换 ThisWorkbook 对象):
ThisWorkbook.EnableAutoRecover = False
对应【Excel 选项】
取消勾选【自动恢复例外情况】中的【仅禁用此工作簿的自动恢复】复选框:
刚才查了一下,好像没有这方面的属性呢
绛旓細1.鍦╒BA缂栬緫鍣ㄤ腑锛屽崟鍑昏彍鍗曗滃伐鍏封啋閫夐」鈥濓紝寮瑰嚭鈥滈夐」鈥濆璇濇銆2.閫夋嫨鈥滅紪杈戝櫒鈥濋夐」鍗★紝鍙栨秷閫夋嫨鈥滆嚜鍔ㄨ娉曟娴嬧濋夐」銆3.鍗曞嚮鈥滅‘瀹氣濇寜閽傝繖鏍疯缃悗锛屽浜庢湁璇硶閿欒鐨勮鍙ワ紝鍥炶溅鍚嶸BA缂栬緫鍣ㄨ櫧涓嶄細寮瑰嚭閿欒鎻愮ず瀵硅瘽妗嗭紝浣嗕粛浼氬皢鍏舵樉绀轰负绾㈣壊 ...
绛旓細1. 鍏ㄥ眬绂佺敤锛堜綔鐢ㄤ簬鎵鏈夊伐浣滅翱锛夛細Application.AutoRecover.Enabled = False瀵瑰簲銆怑xcel 閫夐」銆戝彇娑堝嬀閫夈愪繚瀛樺伐浣滅翱銆戜腑鐨勩愪繚瀛樿嚜鍔ㄦ仮澶嶄俊鎭椂闂撮棿闅斻戝閫夋锛2. 灞閮ㄧ鐢紙浣滅敤浜庢宸ヤ綔绨匡紝鑻ヨ绂佺敤鍏朵粬宸ヤ綔绨胯鏇挎崲 ThisWorkbook 瀵硅薄锛夛細ThisWorkbook.EnableAutoRecover = False瀵瑰簲銆怑xcel 閫夐」銆戝彇娑...
绛旓細鍦ㄢ滀俊浠讳腑蹇冣濆璇濇涓紝閫夋嫨鈥滃畯璁剧疆鈥濋夐」鍗°傚彇娑堝嬀閫夆滃惎鐢ㄦ墍鏈夊畯锛堜笉寤鸿鍦ㄦ湭缁忎俊浠荤殑鎯呭喌涓浣跨敤姝ら」锛夆濋夐」浠ュ強鍏跺畠鍙兘浼鑷姩鎵撳紑瀹忕殑閫夐」锛屼緥濡傗滃惎鐢 VBA 椤圭洰瀵硅薄妯″瀷鍜岀▼搴忛泦璁块棶鈥濄傚崟鍑烩滅‘瀹氣濇寜閽紝骞鍏抽棴鎵鏈夊璇濇銆傝繖鏍凤紝Excel 灏变笉浼氳嚜鍔ㄦ墦寮瀹忎簡銆傚鏋滈渶瑕佸湪宸ヤ綔绨夸腑浣跨敤瀹忥紝鍙互...
绛旓細1.鎸堿lt+F11锛屾墦寮VBA缂栬緫鍣ㄣ2.鍦ㄤ唬鐮佺獥鍙d腑杈撳叆涓嬪垪浠g爜 Sub RemoveAllAutoFilter()Dim sht As Worksheet For Each sht In ActiveWorkbook.Worksheets If sht.AutoFilterMode = True Then sht.AutoFilterMode = False Next End Sub 3.鍏抽棴VBA缂栬緫鍣紝鎸夊揩鎹烽敭Alt+F8锛屾墦寮鈥滃畯鈥濆璇濇锛岄夋嫨鍖呭惈鈥...
绛旓細Workbook.Close 鏂规硶 (Excel)ThisWorkbook.Close True
绛旓細word锛excel鍙互璋冪敤vba浠g爜鏉ユ帶鍒 ,ppt濂藉儚涓嶈锛涘彧璇伙細ActiveDocument.Protect (wdAllowOnlyReading)灞忚斀鍙抽敭鑿滃崟锛欶or i = 1 To ActiveDocument.CommandBars.Count ActiveDocument.CommandBars(i).Enabled = False Next i
绛旓細Application.Calculation = xlCalculationManual '鎵嬪姩閲嶇畻 Application.Calculation = xlCalculationAutomatic '鑷姩閲嶇畻
绛旓細Sub stopDeleSheet()Application.CommandBars(1).Controls(2).Controls(12).Enabled = FalseEnd Sub杩愯鍚庢晥鏋滃鍥撅紝濡傛灉鏀惧湪宸ヤ綔绨挎墦寮浜嬩欢涓紝灏辫兘瀵硅宸ヤ綔绨鑷姩鐢熸晥銆備綘涔熷彲浠ユ妸杩欏彞浠g爜鏀惧湪妯″潡涓綔涓Excel鍔犺浇椤癸紝杩欐牱灏卞彲浠ュ鎵鏈塃xcel鏂囨。鐢熸晥浜 ...
绛旓細ThisWorkbook.close SaveChanges:=True
绛旓細excel涓娇鐢╲ba鍏抽棴excel鐨勪袱绉嶆柟娉曪紝鏈夐渶瑕佺殑鏈嬪弸鍙互鍙傝冩湰鏂囷紝鏉ョ湅鐪嬪惂锛佹楠 1銆侀鍏堟垜浠墦寮涓涓伐浣滄牱琛ㄤ綔涓轰緥瀛愩2銆佷娇鐢╝lt+f11缁勫悎蹇嵎閿繘鍏be缂栬緫鍣紝鎻掑叆涓涓柊鐨勬ā鍧楋紝骞跺湪妯″潡涓緭鍏ヤ互涓嬩唬鐮侊細Sub SendKeysSample()Application.SendKeys (%fx)End Sub 3銆佽繖涓唬鐮佸緢绠鍗曪紝sendkeys鏄簲鐢...