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

[µo°Ý] µ{¦¡°õ¦æ³t«×¶V¨Ó¶VºC

¦^´_ 1# bulletin
¤u§@ªí¤@ª½ªº QueryTables.Add ·s¼WWeb¬d¸ß,Àɮ׶V¨Ó¶VÃe¤j,©ìºCµ{¦¡ªº³t«×
  1. Option Explicit
  2. Sub DELETE_QueryTables()  '¶È¶·°õ¦æ¤@¦¸²M°£©Ò¦³QueryTable
  3.     Dim SH As Worksheet, Q As QueryTable
  4.     For Each SH In Sheets           '¬¡­¶Ã¯ªº¤u§@ªí¶°¦Xª«¥ó
  5.         For Each Q In SH.QueryTables
  6.             Names(Q.Name).Delete    '§R°£ ©w¸q¦WºÙ
  7.             Q.Delete                '§R°£ QueryTable
  8.         Next
  9.     Next
  10. End Sub

  11. Sub Ex()
  12.     Dim stockid
  13.     stockid = 2303
  14.     With Sheets("CFSQ")
  15.         .Rows("1:64").ClearContents
  16.         If .QueryTables.Count > 1 Then
  17.             .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zc3/zc3_" & stockid & ".djhtm"
  18.         Else  '¨S¦³QueryTable®É·s¼W
  19.              .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zc3/zc3_" & stockid & ".djhtm", Destination:=.Range("$A$1")
  20.         End If
  21.         With .QueryTables(1)  '¤£¦A·s¼W
  22.             .AdjustColumnWidth = True
  23.             .RefreshPeriod = 0
  24.             .WebSelectionType = xlSpecifiedTables
  25.             .WebFormatting = xlWebFormattingNone
  26.             .WebTables = "3"
  27.             .WebPreFormattedTextToColumns = True
  28.             .WebConsecutiveDelimitersAsOne = True
  29.             .Refresh BackgroundQuery:=False
  30.         End With
  31.     End With
  32. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2014-2-6 06:43 ½s¿è

¦^´_ 3# bulletin
Sub DELETE_QueryTables()  ½Æ»s¦b¦ó¼Ò²Õ¤W,°õ¦æ¤@¦¸¥i²M°£©Ò¦³¤u§@ªí¤WQueryTable
  1. Option Explicit
  2. Private Sub CommandButton1_Click()
  3.     Dim StartTime, LastRow
  4.     StartTime = Timer
  5.     Application.ScreenUpdating = False
  6.     LastRow = Sheets("sheet1").Range("A2").End(xlDown).Row '§ä¥X³Ì«á¤@µ§¸ê®Æ
  7.     For i = 1 To LastRow
  8.         Dim stockid
  9.         stockid = Range("A" & i).Value
  10.         Application.Wait Now + TimeValue("00:00:01")
  11.         With Sheets("CFSQ")
  12.             .Rows("1:64").ClearContents
  13.             '******************************
  14.             If .QueryTables.Count > 1 Then
  15.                 .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zc3/zc3_" & stockid & ".djhtm"
  16.             Else  '¨S¦³QueryTable®É·s¼W
  17.                 .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zc3/zc3_" & stockid & ".djhtm", Destination:=.Range("$A$1")
  18.             End If
  19.             With .QueryTables(1)  '¤£¦A·s¼W
  20.                 .AdjustColumnWidth = True
  21.                 .RefreshPeriod = 0
  22.                 .WebSelectionType = xlSpecifiedTables
  23.                 .WebFormatting = xlWebFormattingNone
  24.                 .WebTables = "3"
  25.                 .WebPreFormattedTextToColumns = True
  26.                 .WebConsecutiveDelimitersAsOne = True
  27.                 .Refresh BackgroundQuery:=False
  28.             End With
  29.             '******************************
  30.        End With
  31.       
  32.        With Sheets("ISQ")
  33.            .Rows("1:64").ClearContents
  34.            '®M¤W­×§ï .QueryTables(1).Connection =??? .QueryTables.Add Connection=???
  35.        End With
  36.       
  37.        With Sheets("BSQ")
  38.            .Rows("1:64").ClearContents
  39.            '®M¤W­×§ï .QueryTables(1).Connection =??? .QueryTables.Add Connection=???
  40.            '.WebTables = """oMainTable""" ¶·­×§ï
  41.            End With
  42.        End With
  43.        'µ{¦¡½X
  44.        '
  45.        '
  46.     Next
  47. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2014-2-6 13:17 ½s¿è

¦^´_ 5# bulletin
¥t¦s·sÀɮɡA¦³ªºÀɮצ³¤º®e¡A¦³ªºÀɮרS¤º®e¡A·|¬Oºô­¶¤W¨ºÀɪѲ¼¨S¦³¸ê®Æ?
§AªþÀɦsÀɪº³t«×¨S¦³§A»¡ªººC.
  1. Sub DELETE_QueryTables()  '¶È¶·°õ¦æ¤@¦¸²M°£©Ò¦³QueryTable
  2.     Dim SH As Worksheet, Q As Variant
  3.     For Each Q In Names
  4.         Q.Delete
  5.     Next
  6.     For Each SH In Sheets           '¬¡­¶Ã¯ªº¤u§@ªí¶°¦Xª«¥ó
  7.         For Each Q In SH.QueryTables
  8.            Q.Delete
  9.         Next
  10.     Next
  11. End Sub
½Æ»s¥N½X
  1. Private Sub CommandButton1_Click()
  2.     Dim StartTime
  3.     DELETE_QueryTables  '**«Øij¥ý²M°£***
  4.     StartTime = Timer
  5.     Application.ScreenUpdating = False
  6.     LastRow = Sheets("sheet1").Range("A2").End(xlDown).Row '§ä¥X³Ì«á¤@µ§¸ê®Æ
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 7# bulletin
2.©I¥sDelete_Querytables®É¡Aµo¥Í1004¿ù»~
¦]°õ¦æ¤Ó¦h¦¸ªº
  1. With .QueryTables.Add(Connection:=
½Æ»s¥N½X
³y¦¨³\¦hNameªº¦ì¸m³£¬Û¦P,¾É­P²Ä1ª©ªºSub DELETE_QueryTables()ªº¿ù»~
©Ò¥H§ï¥Î ²Ä2ª©ªºSub DELETE_QueryTables()ªºµ{¦¡½X





3.BSQ¤u§@ªíªÅ¥Õ°ÝÃD, ¥i¬d¬O­þ¤@ÀɪѲ¼¬Ýºô­¶¬O§_¤]µL¸ê®Æ
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ­×¦æ­nô½t­×¤ß¡AÂǨƽm¤ß¡AÀH³B¾i¤ß¡C
ªð¦^¦Cªí ¤W¤@¥DÃD