VBA如何禁用Excel工作簿右上角最大化按钮(中间方块按钮)? 如何透过VBA按钮执行保存及关闭工作簿的指令
vba\u7684\u95ee\u9898\uff0c\u600e\u6837\u624d\u80fd\u505a\u5230\u5173\u95ed\u5de5\u4f5c\u7c3f\uff08\u5373\u70b9\u51fb\u8868\u683c\u53f3\u4e0a\u89d2\u201cX\u201d\u6309\u94ae\uff09\u540e\u5c31\u81ea\u52a8\u6253\u5f00\u8868\u5355\uff08\u76f8\u5f53\u4e8e\u5de5\u4f5c\u7c3f\u7684\u6ca1\u770b\u61c2\u4f60 \u8981\u8868\u8fbe\u7684\u95ee\u9898\u662f\u4ec0\u4e48\uff1f
\u5982\u679c\u5728\u5173\u95ed\u4e8b\u4ef6\u4e0b\u52a0\u4e00\u6761\u8c03\u51fa\u5c01\u9762\u7684\u547d\u4ee4\uff0c\u53ef\u6b63\u5e38\u8c03\u51fa\u5c01\u9762\u8868\u5355\uff0c\u4f46\u6253\u5f00\u65f6\u8868\u5355\u4e0a\u7684\u8fd9\u4e2a\u6309\u94ae\u662f\u53ef\u4ee5\u6b63\u5e38\u9000\u51fa\u7684\uff0c\u4e3a\u4ec0\u4e48\uff0c\u60f3\u4e0d\u901a\uff0c
\u4ec0\u4e48\u60f3\u4e0d\u901a\uff1f\uff1f\uff1f\uff1f
excel\u5de5\u4f5c\u8868\u4fdd\u5b58\u53ca\u9000\u51fa\u4ee3\u7801\u5982\u4e0b
sub qui()
ActiveWorkbook.Save
ActiveWorkbook.close
end sub
\u671b\u91c7\u7eb3
Public Sub RemoveX()
HasSystemMenu False '移除工作簿左上角图标和右上角最小化/最大化/关闭按钮
RemoveWindowX '移除工作表左上角图标和右上角最小化/最大化/关闭按钮
End Sub
'‘*****************************
Public Sub RestoreX()
HasSystemMenu True '恢复工作簿左上角图标和右上角最小化/最大化/关闭按钮
RestoreWindowX '恢复工作表左上角图标和右上角最小化/最大化/关闭按钮
End Sub
'‘*****************************
Public Sub RemoveWindowX()
ActiveWorkbook.Protect , , True
End Sub
'‘*****************************
Public Sub RestoreWindowX()
ActiveWorkbook.Protect , , False
End Sub
插入一模块,然后把上述代码复制过去。执行宏RemoveX,即可去除最大最小化按钮。
Private Sub BHide_Click() '移除工作表左上角图标和右上角最小化/最大化/关闭按钮
ActiveWorkbook.Protect , , True
End Sub
Private Sub Bshow_Click() '恢复工作表左上角图标和右上角最小化/最大化/关闭按钮
ActiveWorkbook.Protect , , False
End Sub
绛旓細鍦VBA缂栬緫鍣ㄢ滃伐绋嬧濈獥鍙d腑锛屽弻鍑烩淭hisWorkBook鈥濓紝鍦ㄥ彸杈圭殑浠g爜绐楀彛涓緭鍏ヤ笅闈㈢殑浠g爜锛歅rivate Sub Workbook_BeforePrint(Cancel As Boolean)Cancel = True End Sub 璇ヤ唬鐮佷娇鐢ㄤ簡Workbook.BeforePrint浜嬩欢锛屽湪鎵撳嵃宸ヤ綔绨涔嬪墠鎵ц浠g爜銆傝繖鏍凤紝褰撴垜浠湪璇ュ伐浣滅翱涓夋嫨鈥滄墦鍗扳濇垨鈥滄墦鍗伴瑙堚濆懡浠ゆ椂锛Excel灏嗕笉...
绛旓細1銆侀鍏堟垜浠墦寮涓涓宸ヤ綔鏍疯〃浣滀负渚嬪瓙銆2銆佹垜浠娇鐢╝lt+f11缁勫悎蹇嵎閿繘鍏be缂栬緫鍣紝鎻掑叆涓涓柊鐨勬ā鍧楋紝骞跺湪妯″潡涓緭鍏ヤ互涓嬩唬鐮侊細Option Explicit Sub setcap()ThisWorkbook.Close False End Sub 3銆乧lose鏂规硶蹇呴』鏈変竴涓璞★紝瀵硅薄涓簑orkbooks锛屽湪杩欓噷鎴戜滑浣跨敤鐨則hisworkbook鍙互鐩存帴浣跨敤鍙傛暟銆傝寃orkbooks浣跨敤...
绛旓細1. 鍏ㄥ眬绂佺敤锛堜綔鐢ㄤ簬鎵鏈夊伐浣滅翱锛夛細Application.AutoRecover.Enabled = False瀵瑰簲銆怑xcel 閫夐」銆戝彇娑堝嬀閫夈愪繚瀛樺伐浣滅翱銆戜腑鐨勩愪繚瀛樿嚜鍔ㄦ仮澶嶄俊鎭椂闂撮棿闅斻戝閫夋锛2. 灞閮ㄧ鐢紙浣滅敤浜庢宸ヤ綔绨匡紝鑻ヨ绂佺敤鍏朵粬宸ヤ綔绨胯鏇挎崲 ThisWorkbook 瀵硅薄锛夛細ThisWorkbook.EnableAutoRecover = False瀵瑰簲銆怑xcel 閫夐」銆戝彇娑...
绛旓細鏂规硶1:浣垮垹闄ゅ姛鑳戒笉鍙敤 鎵撳紑鏂囨。鎴栨縺娲绘枃妗e悗鍗充娇鍔熻兘涓嶅彲鐢 Sub DisableDelSheet()Application.CommandBars("edit").Controls(12).Enabled = False Application.CommandBars("ply").Controls(3).Enabled = False End Sub 鍏抽棴鏂囨。鎴栧垏鎹㈡枃妗d箣鍓嶈浣忚鎭㈠鍔熻兘鍙敤 Sub EnableDelSheet()Application.CommandB...
绛旓細浠g爜濡備笅锛歅ublic Sub RemoveX()HasSystemMenu False '绉婚櫎宸ヤ綔绨宸︿笂瑙掑浘鏍囧拰鍙充笂瑙掓渶灏忓寲/鏈澶у寲/鍏抽棴鎸夐挳 RemoveWindowX '绉婚櫎宸ヤ綔琛宸︿笂瑙掑浘鏍囧拰鍙充笂瑙掓渶灏忓寲/鏈澶у寲/鍏抽棴鎸夐挳 End Sub '鈥楶ublic Sub RestoreX()HasSystemMenu True '鎭㈠宸ヤ綔绨垮乏涓婅鍥炬爣鍜屽彸涓婅鏈灏忓寲/鏈澶у寲/鍏抽棴鎸夐挳 ...
绛旓細1.鎸堿lt+F11锛屾墦寮VBA缂栬緫鍣紝鍦ㄢ滃伐绋嬧濈獥鍙d腑鍙屽嚮鈥淭hisWorkBook鈥濓紝鍦ㄥ彸渚х殑浠g爜绐楀彛涓緭鍏ヤ笅鍒椾唬鐮侊細Private Sub workbook_BeforeSave(ByVal SaveAsUI As Boolean, _Cancel As Boolean)Dim response As Long If SaveAsUI = True Then response = MsgBox("璇宸ヤ綔绨涓嶅厑璁哥敤鈥滃彟瀛樹负鈥濇潵淇濆瓨锛" &...
绛旓細Sub stopDeleSheet()Application.CommandBars(1).Controls(2).Controls(12).Enabled = FalseEnd Sub杩愯鍚庢晥鏋滃鍥撅紝濡傛灉鏀惧湪宸ヤ綔绨鎵撳紑浜嬩欢涓紝灏辫兘瀵硅宸ヤ綔绨胯嚜鍔ㄧ敓鏁堛備綘涔熷彲浠ユ妸杩欏彞浠g爜鏀惧湪妯″潡涓綔涓Excel鍔犺浇椤癸紝杩欐牱灏卞彲浠ュ鎵鏈塃xcel鏂囨。鐢熸晥浜 ...
绛旓細鎵撳紑宸ヤ綔琛锛岀偣鍑昏彍鍗曟爮鐨勬枃浠讹紝閫夋嫨鍙﹀瓨涓猴紝鐐瑰嚮鐣岄潰涓婄殑宸ュ叿锛岄噷闈㈡湁瀵嗙爜璁剧疆閫夐」銆(鍦ㄥ父瑙勯夐」閲)
绛旓細浣犳兂绂佺敤鈥滃彇娑堥殣钘忊濆姛鑳斤紝澶ф鏄笉鎯宠鍒汉鐪嬪埌鏌愪簺琛ㄦ牸銆傚叾瀹炴湁鍙﹀鐨勬濊矾瀹炵幇锛1銆佹妸琛ㄦ牸璁剧疆涓烘繁搴﹂殣钘忥紙濡傚浘锛 濡傛灉鐢VBA璇彞闅愯棌锛屼緥濡傦細 Sheets(3).Visible=2 2銆佹妸VBA宸ョ▼鍔犲瘑鐮 (闃叉鍒汉鐩存帴淇敼琛ㄦ牸灞炴ц屽彇娑堥殣钘忥級娣卞害闅愯棌鐨勮〃鏍硷紝鍗充娇鐐瑰彇娑堥殣钘忎篃鐪嬩笉鍒般
绛旓細鐢VBA 缂栧啓锛1) 鎵撳紑鎸囧畾宸ヤ綔绨 dim wb as workbook set wb = " 鏂囦欢璺緞鍙婃枃浠跺悕"workbooks.open filename:= wb 2锛鍏抽棴鎵鏈夊伐浣滅翱骞朵繚瀛 workbooks.close