ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

¦p¦óÂ÷¶}excelµ{¦¡???

¦p¦óÂ÷¶}excelµ{¦¡???

¥»©«³Ì«á¥Ñ sillykin ©ó 2016-10-15 23:41 ½s¿è

¥»¤H¦bµ{¦¡¥[¤F¤U­±¶µ¥Ø,¦ý­n¦p¦ó¦sÀÉ,¨Ã±j¨îÂ÷¶}¦¹µ{¦¡??
Dim closeflag As Boolean
Private Sub workbook_beforeclose(cancel As Boolean)
If closeflag = False Then
cancel = True
MsgBox "¦¹¥\¯à¤w¸g³Q¸T¤î", vbExclamation, "´£¥Ü"
End If
End Sub
Public Sub closeworkbook()
closeflag = True
Me.Close
End Sub
Private Sub workbook_beforesave(ByVal saveasul As Boolean, cancel As Boolean)
If saveasul = True Then
MsgBox "¦¹Àɮפ£¤¹³\¥t¦s·sÀɧ@·~!!", vbOKOnly, "ª`·N"
cancel = True
Else
cancel = False
End If
End Sub

给§A两Ïú¤è¦¡¡G
¤@¡B²K¥[¤@个·sªºSub,¥N码¦p¤U¡G
  1. Sub Test()
  2.   Application.EnableEvents = False
  3. End Sub
½Æ»s¥N½X
µM¦Z运¦æTest这个过µ{¦Z¡A¦A删°£¤W­±ªº¥N码¡AµM¦Z¦s盘¡C

¤G¡B¨Ï¥Î断点测试¡G
¹«标点击Workbook_BeforeSave过µ{ªº²Ä¤@¦æ¥N码
  1. If saveasul = True Then
½Æ»s¥N½X
¡A¨Ï¥Î¥ú标¦b¦¹¦æ闪烁¡AµM¦Z«öF9¦b¦¹¦æ¤U断点(¦¹¦æ«e­±¦³个红点)¡F¦A¦bWorkbook_BeforeClose过µ{ªº²Ä¤@¦æ¥N码
  1. If Closeflag = False Then
½Æ»s¥N½X
处¤U断点¡]¤èªk¦P¤W¡^¡A点击«O¦s¡A这时断点处¥N码会³Q¥[黄©³¡A©ì动¥N码«e­±ªº黄¦â½b头¡A©Ô¨ìEnd Sub(这时End Sub 这¦æ变¦¨黄©³)¡A¦Ó¦Z«öF5运¦æ¡A这¦æ´N¥i¥H«O¦s¤F¡C
¥@¬É¨º»ò¤j¡A¥i§Ú·Q¥h­þ¡H

TOP

        ÀR«ä¦Û¦b : ¦Y­W¤F­W¡B­WºÉ¤Ü¨Ó¡A¨ÉºÖ¤FºÖ¡BºÖºÉ´d¨Ó¡C
ªð¦^¦Cªí ¤W¤@¥DÃD