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

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

¦^´_ 14# bulletin
§Ú§ì¥xÆW50¡Aªá¤F¬ù56¬í¡C

            
With wbnew.Sheets(1) 'CFSQ
               '.Rows("1:64").ClearContents
               
               '******************************
                If .QueryTables.Count > 1 Then
                    .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zc3/zc3_" & stockid & ".djhtm"
                Else  '¨S¦³QueryTable®É·s¼W
                    .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zc3/zc3_" & stockid & ".djhtm", Destination:=.Range("$A$1")
                End If
                With .QueryTables(1)  '¤£¦A·s¼W
                    .AdjustColumnWidth = True
                    .RefreshPeriod = 0
                    .WebSelectionType = xlSpecifiedTables
                    .WebFormatting = xlWebFormattingNone
                    .WebTables = "3"
                    .WebPreFormattedTextToColumns = True
                    .WebConsecutiveDelimitersAsOne = True
                    .Refresh BackgroundQuery:=False
                End With
                '******************************
               
           End With
         
        With wbnew.Sheets(2)
               '.Rows("1:64").ClearContents
               
               '******************************
                If .QueryTables.Count > 1 Then
                    .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zcq/zcq_" & stockid & ".asp.htm"
                Else  '¨S¦³QueryTable®É·s¼W
                    .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zcq/zcq_" & stockid & ".asp.htm", Destination:=.Range("$A$1")
                End If
                With .QueryTables(1)  '¤£¦A·s¼W
                    .AdjustColumnWidth = True
                    .RefreshPeriod = 0
                    .WebSelectionType = xlSpecifiedTables
                    .WebFormatting = xlWebFormattingNone
                    .WebTables = "3"
                    .WebPreFormattedTextToColumns = True
                    .WebConsecutiveDelimitersAsOne = True
                    .Refresh BackgroundQuery:=False
                End With
                '******************************
               
           End With
         
           With wbnew.Sheets(3)
               '.Rows("1:64").ClearContents
               
               '******************************
                If .QueryTables.Count > 1 Then
                    .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zcp/zcpa/zcpa_" & stockid & ".asp.htm"
                Else  '¨S¦³QueryTable®É·s¼W
                    .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zcp/zcpa/zcpa_" & stockid & ".asp.htm", Destination:=.Range("$A$1")
                End If
                With .QueryTables(1)  '¤£¦A·s¼W
                    .AdjustColumnWidth = True
                    .RefreshPeriod = 0
                    .WebSelectionType = xlSpecifiedTables
                    .WebFormatting = xlWebFormattingNone
                    .WebTables = "3"
                    .WebPreFormattedTextToColumns = True
                    .WebConsecutiveDelimitersAsOne = True
                    .Refresh BackgroundQuery:=False
                End With
                '******************************
               
           End With

«Ü©êºp¡A§Ú¬O¤p¾Ç¥Í¡A¤£¯à¤U¸üÀɮסA¬O­Ó¤p§¾«Ä¡I

TOP

¦^´_ 14# bulletin
  1. Sub stest()

  2.         Dim StartTime, LastRow
  3.         Dim wbnew As Workbook
  4.       
  5.         DELETE_QueryTables
  6.       
  7.         StartTime = Timer
  8.         LastRow = Sheets("sheet1").Range("A2").End(xlDown).Row '§ä¥X³Ì«á¤@µ§¸ê®Æ

  9.         Application.ScreenUpdating = False
  10.       
  11.         For i = 1 To 50
  12.             
  13.             Dim stockid
  14.             If i <= 50 Then
  15.                stockid = Range("A" & i + 10).Value
  16.             Else
  17.                stockid = Range("B" & i + 10).Value
  18.             End If
  19.             Application.DisplayAlerts = False
  20.             Application.Wait Now + TimeValue("00:00:01")
  21.             
  22.             
  23.             Set wbnew = Workbooks.Add() '·s¼W¬¡­¶Ã¯
  24.             'wbnew.SaveAs Filename:="C:\myStock\Test\" & stockid & ".xls"  '¥t¦s·sÀÉ
  25.             wbnew.SaveAs Filename:="C:\myStock\Test\" & stockid & "©u³ø.xls"  '¥t¦s·sÀÉ

  26.             With wbnew.Sheets(1) 'CFSQ
  27.                '.Rows("1:64").ClearContents
  28.                
  29.                '******************************
  30.                 If .QueryTables.Count > 1 Then
  31.                     .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zc3/zc3_" & stockid & ".djhtm"
  32.                 Else  '¨S¦³QueryTable®É·s¼W
  33.                     .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zc3/zc3_" & stockid & ".djhtm", Destination:=.Range("$A$1")
  34.                 End If
  35.                 With .QueryTables(1)  '¤£¦A·s¼W
  36.                     .AdjustColumnWidth = True
  37.                     .RefreshPeriod = 0
  38.                     .WebSelectionType = xlSpecifiedTables
  39.                     .WebFormatting = xlWebFormattingNone
  40.                     .WebTables = "3"
  41.                     .WebPreFormattedTextToColumns = True
  42.                     .WebConsecutiveDelimitersAsOne = True
  43.                     .Refresh BackgroundQuery:=False
  44.                 End With
  45.                 '******************************
  46.                
  47.            End With
  48.          
  49.         With wbnew.Sheets(2)
  50.                '.Rows("1:64").ClearContents
  51.                
  52.                '******************************
  53.                 If .QueryTables.Count > 1 Then
  54.                     .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zcq/zcq_" & stockid & ".asp.htm"
  55.                 Else  '¨S¦³QueryTable®É·s¼W
  56.                     .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zcq/zcq_" & stockid & ".asp.htm", Destination:=.Range("$A$1")
  57.                 End If
  58.                 With .QueryTables(1)  '¤£¦A·s¼W
  59.                     .AdjustColumnWidth = True
  60.                     .RefreshPeriod = 0
  61.                     .WebSelectionType = xlSpecifiedTables
  62.                     .WebFormatting = xlWebFormattingNone
  63.                     .WebTables = "3"
  64.                     .WebPreFormattedTextToColumns = True
  65.                     .WebConsecutiveDelimitersAsOne = True
  66.                     .Refresh BackgroundQuery:=False
  67.                 End With
  68.                 '******************************
  69.                
  70.            End With
  71.          
  72.            With wbnew.Sheets(3)
  73.                '.Rows("1:64").ClearContents
  74.                
  75.                '******************************
  76.                 If .QueryTables.Count > 1 Then
  77.                     .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zcp/zcpa/zcpa_" & stockid & ".asp.htm"
  78.                 Else  '¨S¦³QueryTable®É·s¼W
  79.                     .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zcp/zcpa/zcpa_" & stockid & ".asp.htm", Destination:=.Range("$A$1")
  80.                 End If
  81.                 With .QueryTables(1)  '¤£¦A·s¼W
  82.                     .AdjustColumnWidth = True
  83.                     .RefreshPeriod = 0
  84.                     .WebSelectionType = xlSpecifiedTables
  85.                     .WebFormatting = xlWebFormattingNone
  86.                     .WebTables = "3"
  87.                     .WebPreFormattedTextToColumns = True
  88.                     .WebConsecutiveDelimitersAsOne = True
  89.                     .Refresh BackgroundQuery:=False
  90.                 End With
  91.                 '******************************
  92.                
  93.            End With
  94.          
  95.            'Windows(stockid & ".xls").Close savechanges:=True
  96.            Windows(stockid & "©u³ø.xls").Close savechanges:=True
  97.            Application.DisplayAlerts = True

  98.         Next i
  99.       
  100.       
  101.        Application.ScreenUpdating = True
  102.        EndTime = Timer
  103.        MsgBox "¥»¦¸¤U¸ü¦@ªá¶O¡G" & EndTime - StartTime & "¬í"
  104.          
  105.       
  106. End Sub
½Æ»s¥N½X
«Ü©êºp¡A§Ú¬O¤p¾Ç¥Í¡A¤£¯à¤U¸üÀɮסA¬O­Ó¤p§¾«Ä¡I

TOP

        ÀR«ä¦Û¦b : ¦Û¤v®`¦Û¤v¡A²ö¹L©ó¶ÃµoµÊ®ð¡C
ªð¦^¦Cªí ¤W¤@¥DÃD