Sub saveCSVfmURL(selDate As String)
Dim st, nt, mond, dayd
Dim myURL, myURL2 As String
Dim oStream As Object 'ADODB.Stream
Dim WinHttpReq As Object 'XMLHTTP
Dim fileIdx As String
Dim folderLoc As String
Dim twPath As String
Dim twoPath As String
Dim cTw As String
Dim cTwo As String
Dim y1 As String
With WinHttpReq
'.Open "GET", myURL, False
.send
myURL = .responseText
End With
If myURL <> "" Then
Set oStream = CreateObject("ADODB.Stream")
With oStream
.Open
.Type = 1
.Write WinHttpReq.responseBody
fileIdx = twPath & selDate & "_TW.csv"
On Error Resume Next
Kill fileIdx
On Error GoTo 0
.SaveToFile fileIdx
.Close
End With
End If
Set WinHttpReq = Nothing
Set oStream = Nothing
Dim removeSmallFile As Integer
removeSmallFile = ActiveSheet.Shapes("cBox_sFile").ControlFormat.Value
If removeSmallFile = 1 Then
Call fileSizeCheck(twPath)
Call fileSizeCheck(twoPath)
End If
Sub fileSizeCheck(mySourcePath)
Dim OFS As Object
Dim mySource As Object
Dim myFile As Object
Set OFS = CreateObject("Scripting.FileSystemObject")
Set mySource = OFS.getFolder(mySourcePath)
On Error Resume Next
For Each myFile In mySource.Files
If myFile.Size < 10000 Then
Kill myFile
End If
Next
End Sub作者: joey0415 時間: 2019-6-29 09:47