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

[µo°Ý] ¦p¦ó¥ÎVBA¡A³z¹LExcel¦bºô­¶¤W±±¨î¤Ä¿ï?

[µo°Ý] ¦p¦ó¥ÎVBA¡A³z¹LExcel¦bºô­¶¤W±±¨î¤Ä¿ï?

:)  Hi ¦U¦ì¥ý¶i
·Q½Ð±Ð¤@­Ó°ÝÃD¡A´N¬O¦bºô­¶¤W¡A¦³¤@­Ó¥´¤Äªº¤è®Ø¡A¦p¤U¹Ï¬õ®Øªº¦a¤è¡A¦pªG§Ú·Q¥ÎVBAµ{¦¡»y¨¥±±¨î¡A¤ñ¤è§Ú¦bExcel A1¤å¦rÅã¥Ü "¶µ¦¸"¡A¦bA2 Äæ¦ì¨Ó§P©w¬O§_¬°"Y"¡A°²¨ÏA2¬°Y¡Aºô­¶¤W¶µ¦¸ªº®Ø®Ø¤º´N¥´¤Ä¡A³o¦n¹³¸òchecked¦³Ãö¡A¦]¬°§Úµo²{¨S¦³³Q¥´¤Äªº¿ï¶µ¡Avalue¨º¤@¦ê¦r¤§«áªº checked ¤£·|Åã¥Ü
ÁÂÁ«ü±Ð

------³Q¤Ä¿ïªº®Ø "¶µ¦¸" ºô­¶­ì©lÀÉ
<td width="26%" align="left" bgcolor="#EEEEEE" class='t8_blue4'>&nbsp;&nbsp;&nbsp;
<INPUT type="checkbox" name="displayAttribute" id="displayAttribute1" value="SequenceNo" checked>
&nbsp;¶µ¦¸
</td>

------¨S³Q¤Ä¿ïªº®Ø "¥Î¶q(*) ºô­¶­ì©lÀÉ
<td width="26%" align="left" bgcolor="#EEEEEE" class='t8_blue4'>&nbsp;&nbsp;&nbsp;
<INPUT type="checkbox" name="displayAttribute" id="displayAttribute5" value="QuantityStar" >
&nbsp;¥Î¶q(*)
</td>

¦^´_ 1# espionage
¸Õ¸Õ¬Ý
  1. Option Explicit
  2. Sub Ex()
  3.     Dim E As Object
  4.     With CreateObject("InternetExplorer.Application")
  5.         .Visible = True
  6.         .Navigate "D:\A.HTM"  '­×¥¿¬°§Aªººô­¶
  7.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  8.         '<INPUT type="checkbox" name="displayAttribute" id="displayAttribute1" value="SequenceNo">
  9.         '<INPUT type="checkbox" name="displayAttribute" id="displayAttribute5" value="QuantityStar" >
  10.         With .Document            '
  11.            'TagName= "INPUT", ¤£¬O°ß¤@ªº
  12.            'For Each E In .all.tags("input")  '=>.getElementsByTagName("INPUT")
  13.            '     If E.Value = "SequenceNo" Then E.Checked = [A2] = "Y"
  14.            '     If E.Value = "QuantityStar" Then E.Checked = [B2] = "Y"
  15.            'Next
  16.            'name="displayAttribute"¤£¬O°ß¤@ªº
  17.            'For Each E In .all("displayAttribute")  '=>.getElementsByName("displayAttribute")
  18.            '    If E.Value = "SequenceNo" Then E.Checked = [A2] = "Y"
  19.            '    If E.Value = "QuantityStar" Then E.Checked = [B2] = "Y"
  20.            'Next
  21.             'id="displayAttribute1",id="displayAttribute5"
  22.             'id ¬O°ß¤@ªº
  23.             
  24.             '¤Ä¿ïªº®Ø "¶µ¦¸"
  25.             .getElementByID("displayAttribute1").Checked = [A2] = "Y"
  26.             '¤Ä¿ïªº®Ø "¥Î¶q(*)"
  27.             .getElementByID("displayAttribute5").Checked = [B2] = "Y"
  28.         End With
  29.         '.Quit        'Ãö³¬ºô­¶
  30.     End With
  31. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

GBKEE ¤j¤j
§Ú¦n¹³Åý±z»~·|¤F¡A§Úªº·Qªk¬O¡A¦pªG¦bExcel¤Wªº¬Y­ÓÄæ¦ì¼Ð¥Ü"Y"¡A¥i¥H±±¨îWeb¤WÄæ¦ì¤Wªº¿ï¶µ¬O§_¥´¤Ä
¤ñ¤èExcel§Ú¦bB3Äæ©ñ¤JY¡A«h¦¹ºô­¶¦b "¿ï¶µ" ªº³o­Ó¤è®Ø¤º¡A´N·|³Q¥´¤Ä
¤£¹LVBA³ø¿ù¡A»¡¨S³o­Ó»yªk¡A§ÚÀ³¸Ó«ç­Ó§ï¤ñ¸û¦n©O?

  '-----Äæ¦ì¶µ¦¸¿ï¶µ
  For Each A In .getelementbyid("displayAttribute1")
  If Sheets(1).Cells(3, 3) = "Y" Then A.Checked  '¦pªGExcel B3Åã¥Ü Y¡A«h§âºô­¶ "¶µ¦¸" ¿ï¶µ¥´¤Ä
  Next

TOP

¤j¤j
ÁÂÁ«e­±ªº«ü¾É¡A§Ú­è¸Õ¥X¨Ó¤F  
'If Sheets(1).Cells(3, 2) = "Y" Then ' ---->³o¥y§PÂ_if¡A¬O¦hªº¡AÀ³¸Ó§R°£
¥u­n¯d  .getelementbyid("displayAttribute7").Checked = Sheets(1).Cells(3, 2) ´N¦n¤F
¦pªGB3Äæ¦ì¦³¤º®e¡A¿ï¶µ´N·|¤Ä°_¨Ó¤F¡A¦pªGB3Äæ¦ìµL¤º®e¡A¿ï¶µ´N¤£·|¤Ä°_¨Ó¤F
·PÁÂ

    '-----Äæ¦ì¶µ¦¸¿ï¶µ---------
  'If Sheets(1).Cells(3, 2) = "Y" Then ' ³o¥y¬O¦hªº¡AÀ³¸Ó§R°£
  .getelementbyid("displayAttribute7").Checked = Sheets(1).Cells(3, 2) '¦pªGExcel B3Åã¥Ü Y¡A«h§âºô­¶ "¶µ¦¸" ¿ï¶µ¥´¤Ä

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2015-9-22 05:45 ½s¿è

¦^´_ 4# espionage

   
§Ú¦n¹³Åý±z»~·|¤F¡A§Úªº·Qªk¬O
¦n¹³¨S¦³»~·|.

§Ú¦³»¡¨ì
  1.   'id="displayAttribute1",id="displayAttribute5"
  2.             'id ¬O°ß¤@ªº¨S¦³¤lª«¥ó
  3. ©Ò¥H   For Each A In .getelementbyid("displayAttribute1") µ{¦¡¶Ç¦^¿ù»~
½Æ»s¥N½X
­n§ï¬°
  1. Set A = .getelementbyid("displayAttribute1")
  2.         If Sheets(1).Cells(3, 3) = "Y" Then A.Checked = True
½Æ»s¥N½X
²¤Æ
  1. .getelementbyid("displayAttribute1").Checked = [A2] = "Y"
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

GBKEE¤j¤j
ÁÂÁ±z¡A¥i¥H¨Ï¥Î

TOP

        ÀR«ä¦Û¦b : ¹D¼w¬O´£ª@¦Û§Úªº©ú¿O¡A¤£¸Ó¬O¨þ¥¸§O¤HªºÃ@¤l¡C
ªð¦^¦Cªí ¤W¤@¥DÃD