- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¥»©«³Ì«á¥Ñ GBKEE ©ó 2014-4-26 15:42 ½s¿è
¦^´_ 26# smart3135
¤j¬ùn¯Ó®É40¤ÀÄÁ¥H¤W,¬O¦³ÂI¤[,¹q¸£n´îªÎ¤F
«Øij´îªÎ¤è¦¡¦p¤U
1±N¤U±¤å¦r½Æ»s¨ì°O¨Æ¥» ¦sÀɬ°ªþÀɦW ".BAT",¶Ç°e¨ì®à±¤W ,¤£©w®Éªº²M²z©U§£ÀÉ®×
2¤£©w®Éªº²MªÅ¸ê·½¦^¦¬µ©
3 ¤£©w®É²MªÅIEªºÂsÄý°O¿ý
4 ©w®Éªº²M²zºÏºÐ
5ÂX¥R°O¾ÐÅé
4203¤Ñ¤¯(«á§ì¨ú)¬O¿ù»~ªºªÑ²¼¸¹½X,³o¨ÇªÑ²¼¦WºÙ(¥N¸¹) ³sÄò¤@°_¿é¤J¦bSheets(2)ªºAÄæ
- Option Explicit
- Sub §ì©u¤ëÀ禬¸ê®Æ()
- Dim E As Integer, URL As String, xPath As String, xFile As String
- Dim i As Integer, ii As Integer, Rng As Range, S1 As String, S2 As String, t As Date
- Dim AR()
- t = Time
- AR = Array(4203) '¿é¤J 4203¤Ñ¤¯(«á§ì¨ú)¬O¿ù»~ªºªÑ²¼¸¹½X
- URL = "URL;https://djinfo.cathaysec.com.tw/Z/ZC/ZCH/ZCH.DJHTM?A="
- xPath = "D:\°]³ø¸ê®Æ"
- With ThisWorkbook
- .Sheets(2).UsedRange.Offset(, 1).Clear
- '4203¤Ñ¤¯(«á§ì¨ú)¬O¿ù»~ªºªÑ²¼¸¹½X ³o¨Ç ªÑ²¼¦WºÙ(¥N¸¹) ³sÄò¤@°_¿é¤J¦bSheets(2)ªºAÄæ
- Set Rng = .Sheets(2).Range("A:A").SpecialCells(xlCellTypeConstants)
- If Rng Is Nothing Then
- AR = Array()
- ElseIf Rng.Count = 1 Then
- AR = Array(Rng.Value)
- Else
- AR = Application.Transpose(Application.Transpose(Rng))
- End If '***************************************************
- Application.ScreenUpdating = False
- Application.StatusBar = " "
- With .Sheets(1) '¬¡¶Ã¯ªº²Ä 1 ±i¤u§@ªí
- If .QueryTables.Count = 0 Then
- With .QueryTables.Add(Connection:=URL, Destination:=.Range("$A$1"))
- .Refresh BackgroundQuery:=False
- End With
- End If
- .Rows(1).Delete
- .Columns(1).Delete
- For E = 1101 To 5000
- With .QueryTables(1)
- .Connection = URL & E
- .PreserveFormatting = True
- .BackgroundQuery = True
- .RefreshStyle = xlInsertDeleteCells
- .SaveData = True
- .AdjustColumnWidth = True
- .RefreshPeriod = 0
- .WebSelectionType = xlSpecifiedTables
- .WebFormatting = xlWebFormattingNone
- .WebTables = "3"
- .WebPreFormattedTextToColumns = True
- .WebConsecutiveDelimitersAsOne = True
- .Refresh BackgroundQuery:=False
- If .ResultRange(1) < 0 Or InStr(.ResultRange(2, 1), "¬dµL") Then GoTo xLnext
- '¶×¤J¸ê®Æªº A1 < 0 OR ¶×¤J¸ê®Æªº A2 "¬dµL"
- S1 = .ResultRange(1)
- S2 = Mid(S1, 1, InStr(S1, "(") - 1) 'ªÑ²¼¦WºÙ
- End With
- With ThisWorkbook.Sheets(2).Range("B:B")
- Set Rng = .Find(S2, lookat:=xlPart) '·j´M:ªÑ²¼¦WºÙ
- If Rng Is Nothing Then
- i = i + 1
- .Range("A" & i) = S1 'ªÑ²¼¦WºÙ¥N½X
- Else
- Rng.Cells(1, 2) = S1 '«½ÆªºªÑ²¼
- If UBound(Filter(AR, E)) > -1 And UBound(AR) > -1 Then
- 'Filter(AR, E) > -1 '¤ñ¹ï¨ì¦p4203¤Ñ¤¯(«á§ì¨ú)¬O¿ù»~
- Rng.Cells(1, 2) = Rng.Cells(1, 2) & "***" '«á§ì¨ú¬O¿ù»~
- GoTo xLnext:
- End If
- S2 = Mid(Trim(Rng), InStr(Trim(Rng), "(") + 1)
- S2 = Mid(S2, 1, Len(S2) - 1) 'ªºªÑ²¼[¥N½X]
- xFile = xPath & "\" & S2 & "\*.*" '±þ±¼©Ò¦³ÀÉ®×
- If Dir(xFile) <> "" Then
- ii = ii - 1
- Kill xFile
- xFile = xPath & "\" & S2
- If Dir(xFile, vbDirectory) <> "" Then RmDir xFile '¸ê®Æ§¨¤]§R°£¤F
- End If
- End If
- End With
- ii = ii + 1
- xFile = xPath & "\" & E & "\REVENUE.txt"
- MkDir_Sub xFile
- Maketxt xFile, .QueryTables(1)
- xLnext:
- S1 = " " & Sheets(1).QueryTables(1).ResultRange(1)
- If Val(S1) < 0 Then S1 = " ¬dµL"
- Application.StatusBar = Application.Text(Time - t, ["MM¤ÀSS¬í"]) & " " & E & S1
- Next
- End With
- End With
- Application.ScreenUpdating = True
- Application.StatusBar = Application.Text(Time - t, ["MM¤ÀSS¬í"]) & " Ok "
- MsgBox "¶×¤J ¤å¦rÀÉ" & ii & " ¶O®É " & Application.Text(Time - t, ["MM¤ÀSS¬í"])
- End Sub
- Private Sub Maketxt(xF As String, Q As QueryTable) '±N¶×¤J¸ê®Æ¦s¤J«ü©wªºtxt
- Dim fs As Object, E As Range, C As Variant
- Set fs = CreateObject("Scripting.FileSystemObject")
- Set fs = fs.CreateTextFile(xF, True) '³Ð¨£¤@ÓÀÉ®×,¦pÀɮצs¦b¥iÂл\±¼
- For Each E In Q.ResultRange.Rows
- C = Application.Transpose(Application.Transpose(E.Value))
- C = Join(C, vbTab)
- fs.WriteLine C
- Next
- fs.Close
- End Sub
½Æ»s¥N½X |
-
-
EX.JPG
(136.56 KB)
|