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

Application.EnableEvents = True ¥¢®Ä

Application.EnableEvents = True ¥¢®Ä

1.xls¤w¶}±Ò Application.EnableEvents = True §@¥Î¤¤
¶}¤F2.xls «á, 1.xlsµo¥Í¨Æ¥óPrivate Sub Worksheet_Calculate()³£µLªk§@¥Î??

sub test()
Application.EnableEvents = False   '¤w´ú¸Õ¦³µL¦¹¦æ¨S®t
   For Each wb In Workbooks
  If wb.Name = "2.xls" Then GoTo 58
    Next
Workbooks.Open Filename:="k:\xls3\2.xls"
58:
If Windows("2xls").Visible = False Then
Windows("2.xls").Visible = True
ElseIf Windows("2.xls").Visible = True Then
Windows("2.xls").Visible = False
End If
Application.EnableEvents = True  'event¤wµLªk§@¥Î
End Sub

­n¦b1.xls°õ¦æ
sub tes2()
Application.EnableEvents = True
end sub
¤~·|­«°_§@¥Î

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2022-11-20 16:47 ½s¿è

¦^´_ 1# t8899

·íµ{§Ç½ÆÂø¨ì¤@©wµ{«× ·|²£¥ÍÃþ¦ü°ÝÃD

³Ì²×¸Ñ¨M¤è®×´N¬O³]¤@­Ó¼s°ìÅܼÆ

©ñ¦bµ{§Ç¥~

¨Ò¦p
public xxx as boolean
sub test()
xxx = true
end sub

³o¼Ë³B²z«á
¦bIJµo¨Æ¥ó
´N¯à¥Î if xxx= false then ªº¤è¦¡Á׶}


¦ýÁÙ¦³¤@ºØ±¡ªp ¤ñ¸û¯S§O  
§A¹J¨ìÀ³¸Ó¬O³oºØ±¡ªp ¸I¨ì¦³¶}±Ò¤u§@諸¾Þ§@
Ãö³¬ªºexcel ¥»¨­ÁÙ¦b­I´º¨Ã¥¼¯u¥¿Ãö³¬  ¤j·§´N¬O¾ã¤ù³£¦Ç¦âªº

³oºØ¤è¬O§Ú¥Ø«e¥uª¾¹D¤@ºØ¸Ñ¨M¤è¦¡ (©Î³\ÁÙ¦³§ó¦nªº¤èªk ½Ð°ª¤â¸É¥R)

´N¬O¥Îset ªº¤è¦¡¶}±Ò¤u§@ï ÁקKÃö³¬Ãö¤£°®²b
Set ob = CreateObject("Excel.Application")
ob.Visible = False
Set os = ob.Workbooks.Open(¸ô®|)
Set osh = ob.Sheets("¤u§@ªí1")
ob.ActiveWorkbook.Close
ob.Quit
Set ob = Nothing
Set os = Nothing
Set osh = Nothing

TOP

¥»©«³Ì«á¥Ñ t8899 ©ó 2022-11-20 19:39 ½s¿è
¦^´_  t8899

·íµ{§Ç½ÆÂø¨ì¤@©wµ{«× ·|²£¥ÍÃþ¦ü°ÝÃD

³Ì²×¸Ñ¨M¤è®×´N¬O³]¤@­Ó¼s°ìÅܼÆ

©ñ¦bµ{§Ç¥~ ...
singo1232001 µoªí©ó 2022-11-20 16:44

Set os = ob.Workbooks.Open(¸ô®|)
³o«ü¥OÁÙµLªk¶}ÀÉ?½Ð±Ð¦p¦ó¶}ÀÉ?

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2022-11-20 20:36 ½s¿è

¦^´_ 3# t8899


    ob.Visible = False ¥ý§ï¦¨ ob.Visible = true  
­Y­n­I´º³B²z¤~¥Î
    ob.Visible = False  
§Ú½Æ»s®É§Ñ¤F§ï

¥t¥~¸ô®|­n§ï¦¨§Aªº§¹¾ã¸ô®| ¸ò¤§«eopen¤è¦¡ªº¸ô®|¤@¼Ë

³Ì«á­n¦bª`·N¤@¤U    ob.Visible = False ªº±¡ªp¤U ¤¤Â_µ{§Ç ¥i¯à·|¥dbug
¦b­I´º¨SÃö³¬  ¨º´N±o¥Î¤u§@ºÞ²z­û¥hÃö³¬excel¤F
´N¦p¦P§A¶}±Ò¤F¤@­Ó¬Ý¤£¨£ªºexcel ¥d¦b­I´ºÃö¤£±¼

TOP

¥»©«³Ì«á¥Ñ t8899 ©ó 2022-11-21 06:50 ½s¿è
¦^´_  t8899


    ob.Visible = False ¥ý§ï¦¨ ob.Visible = true  
­Y­n­I´º³B²z¤~¥Î
    ob.Visibl ...
singo1232001 µoªí©ó 2022-11-20 20:33


1 ob.Visible = true  
³o¦æ°õ¦æ§¹·|¦h¤@­Ó¨S¥Îªº¦Ç¦âµøµ¡ (¨S¥Î¨ì)¡A¥i§_¬Ù±¼?

2 ¤Ö¤@¦æ  Public ob As Object  ?
ob.ActiveWorkbook.Close
ob.Quit
Set ob = Nothing
Set os = Nothing
Set osh = Nothing
ÃöÀɳo5¦æ©ñ¦b¥t¤@¥¨¶°¡AµLªk¦¨¥\ ?

3 ob.ActiveWorkbook.Close
³o©R¥OÃö³¬·|°Ý­n¤£­n¦sÀÉ??½Ð±Ð­n¦s¸ò¤£­n¦s«ü¥O¦p¦ó¤U?

TOP

¦^´_ 5# t8899

20221121.zip (22.17 KB)

TOP

§Ú­ì¥»ªº°ÝÃD¤w¸g¸Ñ¨M¤F¡A¶}ÀÉ«á¼È°±15¬í´N¸Ñ¨M¤F
2.xls ¸Ì­±¦³940­Ó¸ê®Æ¥æ´«(DDE)­nµ¥¨ì§¹¥þ§ó·s§¹¡A¤~¥i¥H°õ¦æ Application.EnableEvents = True
15¬íªºµ¥«Ý¡A­ì¥»¥ÎDO loop¡A¦]¬°§ó·s¨S¦³¶¶§Ç¡A¤£ª¾³Ì«á¤@µ§§ó·s¬O¨º¤@µ§?¥u¦n§ì15¬íªºµ¥«Ý®É¶¡
Workbooks.Open Filename:="k:\xls3\2.xls"
DSTOP = Now: Do While Now - DSTOP < TimeValue("0:00:15"): DoEvents: Loop '¼È°±15¬í
¦h¾Ç¤F¤@­Ó¶}Àɪº¤èªk¤]¤£¿ù

TOP

        ÀR«ä¦Û¦b : §g¤l¬°¥Ø¼Ð¡A¤p¤H¬°¥Øªº¡C
ªð¦^¦Cªí ¤W¤@¥DÃD