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

[µo°Ý] ¦³¨â­Ó¿W¥ßEXCEL¡A¦p¦óª¾¹D¤Á´«¨ì¥t¤@­Ó¿W¥ßEXCEL¡H

[µo°Ý] ¦³¨â­Ó¿W¥ßEXCEL¡A¦p¦óª¾¹D¤Á´«¨ì¥t¤@­Ó¿W¥ßEXCEL¡H

¦U¦ì«e½ú­Ì¤j®a¦n¡A

¥H A.xlsm ¬°¤¤¤ß¡]½Ð·f°t¤U¹Ï)¡A­Y¤Á´«¨ì C.xlsx¡]ÄݦP¤@­Ó¿W¥ßEXCEL 1)¡A«h·|IJµo Private Sub Workbook_Deactivate() µ{§Ç¡C
­Y±q A.xlsm ¤Á´«¨ì A2.xlsx¡]ÄÝ©ó¥t¤@­Ó¿W¥ßEXCEL 2)¡A«o¤£·|IJµo Private Sub Workbook_Deactivate() µ{§Ç¡C



¤ß±o¡G
IJµoPrivate Sub Workbook_Deactivate() ¥u¯à¦b¦P¤@­Ó¿W¥ßEXCEL¤ºªº¬¡­¶Ã¯¶¡¤Á´«¡A¤~´N·|°õ¦æ¸Óµ{§Ç¡C
¦ý¡A­Y¬O¤Á´«¥t¤@­Ó¿W¥ßEXCEL®É¡A¹ïA.xlsm¦Ó¨¥¬O¨S¦³Åܤƪº¡C

°ÝÃD¡G
¥N½X¸Ó¦p¦ó­×¥¿¡H¤~¯àª¾¹D¦³¤Á´«¨ì¥t¤@­Ó¿W¥ßEXCEL¡C
½Ð¦U¦ì«e½ú­Ì¥X¤â¬Û±Ï¡I·P®¦¡I
  1. Private Sub Workbook_Deactivate()
  2. msgbox "¦³¤Á´«"  
  3. End Sub
½Æ»s¥N½X

¦^´_  justintoolbox
§Ú§Æ±æ¯àÂÇ¥ÑIJµoµ{§Ç§i¶D§Ú¦³¤Á´«¨ì¥t¤@­Ó¿W¥ßEXCEL.
VBA Application ª«¥óªº¨Æ¥ó ...
GBKEE µoªí©ó 2015-7-28 11:05


¤Q¸U¤À·PÁÂGBKEEª©¥D«üÂI°g¬z¡I
Åý§Ú¹ï³o¤è­±¦³·sªº»{ÃÑ¡I
·PÁ¡I

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2015-7-28 11:07 ½s¿è

¦^´_ 18# justintoolbox
§Ú§Æ±æ¯àÂÇ¥ÑIJµoµ{§Ç§i¶D§Ú¦³¤Á´«¨ì¥t¤@­Ó¿W¥ßEXCEL.
VBA Application ª«¥óªº¨Æ¥ó§ä¤£¨ì¤ä´©ªº¨Æ¥ó.
³o´N¬O¨â­Ó¿W¥ßEXCEL.ª«¥óÃþ§OªºApplication¨Æ¥ó.¥i±oª¾¥t¤@­Ó¿W¥ßEXCELªº¬¡°Ê.
  1. Option Explicit
  2. Dim WithEvents APP As Application
  3. Property Set The_App(P As Object)
  4.     Set APP = P    ' ±N APP Äݩʭȳ]¦¨ª«¥ó¡C
  5.     With APP
  6.         .Visible = True
  7.     End With
  8. End Property

  9. Private Sub APP_NewWorkbook(ByVal Wb As Workbook)
  10.     MsgBox Wb.Name
  11. End Sub
  12. Private Sub APP_SheetChange(ByVal Sh As Object, ByVal Target As Range)
  13.     MsgBox Target.Address(, , , 1, 1)
  14. End Sub

  15. Private Sub APP_WindowActivate(ByVal Wb As Workbook, ByVal Wn As Window)
  16.    
  17.     MsgBox "¶i¤J " & Wb.Name
  18. End Sub

  19. Private Sub APP_WindowDeactivate(ByVal Wb As Workbook, ByVal Wn As Window)
  20.     MsgBox "°h¥X " & Wb.Name
  21. End Sub

  22. Private Sub APP_WindowResize(ByVal Wb As Workbook, ByVal Wn As Window)
  23.     MsgBox Wn.Caption & "ÅܤƵøµ¡"
  24. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_  justintoolbox



Module1ªºµ{¦¡½Xª«¥óÃþ§O¼Ò²Õ Class1 ªºµ{¦¡½X
GBKEE µoªí©ó 2015-7-27 14:02


«D±`·PÁÂGBKEEª©¥D¥X¤â¬Û±Ï!
GBKEEª©ªº¥N½X ¬O§Q¥ÎExµ{§Ç,«Ø¥ß¥X¤@­Ó¿W¥ßEXCEL, ¨ÃŪ¨ú·s«Ø¥ßªºEXCELªºÀɦW»P·Æ¹«¿ï¾Üªº¦ì¸m.

¥u¬O.....
¥i¯à§Ú«e­±¨S¦³¸Ô­z²M·¡,¯uªº«Ü©êºp.ÅýGBKEE¤j»~·|¤F.
§Ú­ì¥»´Á±æ¬O:
¤w¸g¦s¦bªº¨â­ÓEXCEL,¦ý³o¨â­Ó³£¬O¦U¦Û¿W¥ßªº(¤£¦P¤@­Óapplication),
¦pªG³o®É­Ô§Ú±qA.xlsm¤Á´«¨ì¥t¤@­ÓEXCEL®É, §Ú§Æ±æ¯àÂÇ¥ÑIJµoµ{§Ç§i¶D§Ú¦³¤Á´«¨ì¥t¤@­Ó¿W¥ßEXCEL,¤£»Ý­nª¾¹DÀɦW¨SÃö«Y.
(¨â­Ó¬¡­¶Ã¯­Y¦b¦P¤@­Óapplication®É,¥i¥H§Q¥ÎWorkbook_DeactivateIJµoµ{§Ç,´Nª¾¹D¦³¤Á´«¨ì¥t¤@­Óµ{§Ç,¦ý­Y¬O¨â­Ó¿W¥ßEXCEL´N¤£¯à¥Î³o­Ó¤èªk¤F)

¤£ª¾¹D³o¼Ë¸ÑÄÀ¦³¨S¦³ÅýGBKEE²M·¡¤@¨Ç,©êºp¦]¬°¦P¤@­Ó°Q½×¦ê°Ý¤F³\¦h°ÝÃD,®e©öÅý¤H¤£ª¾¹D²{¦bªº°ÝÃD¬O¤°»ò,·|®e©ö·d²V..©êºp.

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2015-7-27 14:03 ½s¿è

¦^´_ 16# justintoolbox



Module1ªºµ{¦¡½X
  1. Option Explicit
  2. Public xApp As New Class1
  3. Dim NewApp As New Application
  4. Sub Ex()
  5.     Set xApp.The_App = NewApp
  6. End Sub
½Æ»s¥N½X
ª«¥óÃþ§O¼Ò²Õ Class1 ªºµ{¦¡½X
  1. Option Explicit
  2. Dim WithEvents APP As Application
  3. Property Set The_App(P As Object)
  4.     Set APP = P    ' ±N APP Äݩʭȳ]¦¨ª«¥ó¡C
  5.     With APP
  6.         .Visible = True
  7.         With .Workbooks.Add
  8.             .Sheets(1).[a1] = 5
  9.         End With
  10.     End With
  11. End Property

  12. Private Sub APP_NewWorkbook(ByVal Wb As Workbook)
  13.     MsgBox Wb.Name
  14. End Sub
  15. Private Sub APP_SheetChange(ByVal Sh As Object, ByVal Target As Range)
  16.     MsgBox Target.Address(, , , 1, 1)
  17. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦U¦ì«e½ú­Ì¤j®a¦n¡A

¥H A.xlsm ¬°¤¤¤ß¡]½Ð·f°t¤U¹Ï)¡A­Y¤Á´«¨ì C.xlsx¡]ÄݦP¤@­Ó¿W¥ßEXCEL 1)¡A«h·|IJµo ...
justintoolbox µoªí©ó 2015-7-26 07:05


¦U¦ì«e½ú­Ì¡A¤£ª¾¹D¯à§_°µ¨ì ¤Á´«¨ì¥t¤@­Ó¿W¥ßEXCEL®ÉIJµoµ{§Ç¡H
«ô°U¦U¦ì°ª¤â«e½ú­Ì¸Ñ´b¡I

TOP

¤]«D±`·PÁÂbobomi¤j©n¡I
¬Q¤Ñ§Ú¤]¦³¬Ý¨ì§A¶K¶W³sµ²¡A¥u¬O¤µ¦­´N¨S¬Ý¨£¤F¡A¥i¯à¬O¨t²Îªº°ÝÃD§a¡C

¯à ...
justintoolbox µoªí©ó 2015-7-26 06:44


ºô§}:
https://social.msdn.microsoft.com/Forums/office/en-US/e3e99712-01a7-483e-bf0e-52bb1f94889c/how-to-use-accessibleobjectfromwindow-api-in-vba-to-get-excel-application-object-from-excel?forum=exceldev

ÁÙ¦³¤£¦n·N«äÅýbobomi«e½ú±z¤£¶}¤ß¡A¥H«á¦^¤å§Ú·|ª`·N¥[¤W°Ñ¦Ò¸ê®Æ¨Ó·½¡A§Æ±æ±z¯à¨£½Ì¡I

TOP

³sªþ¤W­ì³ÐªÌµª®×ªº³sµ²³£·|²ö¦W¨ä§®³Q¬å.... µL¨¥
bobomi µoªí©ó 2015-7-26 06:36


¤]«D±`·PÁÂbobomi¤j©n¡I
¬Q¤Ñ§Ú¤]¦³¬Ý¨ì§A¶K¶W³sµ²¡A¥u¬O¤µ¦­´N¨S¬Ý¨£¤F¡A¥i¯à¬O¨t²Îªº°ÝÃD§a¡C

¯à§_¦A´£¨Ñ§A¬Q¤Ñªººô¯¸³sµ²©O¡H
Åý§Ú¤]¤@¨Ö§l¦¬¡A¦A¦¸·PÁ±z¡I

TOP

[ª©¥DºÞ²z¯d¨¥]
  • GBKEE(2015/7/26 07:14): ¤£¦n·N«ä,¨S¬Ý²M·¡¬O³sµ²ºô§},´N§R¤å,½Ð­«µo¤å.

³sªþ¤W­ì³ÐªÌµª®×ªº³sµ²³£·|²ö¦W¨ä§®³Q¬å.... µL¨¥

TOP

¸Õ¸Õ¬Ý(´ú¸ÕÀô¹Ò : Win7 + Office2013)
azrael19 µoªí©ó 2015-7-25 18:22


«z¡I«z¡I«z¡I¯uªº¤Ó....¤Ó´Î¤F¡I
«D±`·PÁÂazrael19¤j¡A¥X¤â¬Û±Ï¡I¡]³sÀɮ׸ô®|³£À°¦£Â^¨ú¥X¨Ó¤F¡A¤Ó·P°Ê¤F¡I¡^
­ì¨Ó»Ý­n³o»ò¦hªº¥N½X¤~¯àª¾¹DÀɦW(¦½ÃC¤¤...)¡A
¬Ý¨Ó³o»Ý­nªá¤@¨Ç®É¶¡¥h²z¸Ñ»P§l¦¬¡A¦A¦¸·PÁÂazrael19¤j¡I

TOP

        ÀR«ä¦Û¦b : ®É®É¦n¤ß´N¬O®É®É¦n¤é¡C
ªð¦^¦Cªí ¤W¤@¥DÃD