COCO研究院

 找回密碼
 註冊
搜索
查看: 2371|回復: 4

[求檔] 請各位高手幫忙看一下,程式名稱未顯示在巨集裡不能執行

[複製鏈接]
發表於 13-10-16 23:26 | 顯示全部樓層 |閱讀模式
Dear 各位大大
   小弟 google 了四處,並參考了別位大大的寫法,要自動抓取 1 年內的股票的歷史價格,問題來了。
   一開始程式還能執行,結果今天改了一下,巨集就無法顯示和執行,可以請各位大大幫忙看一下嗎??
   因為還是新手,一直顯示不能發行 url ,所以拿掉兩行,但不影嚮運行


Sub stock(seldate As String)
Dim myURL As String
Dim oStream As Object           'ADODB.Stream
Dim WinHttpReq As Object            'XMLHTTP
Dim fileIdx As String
Dim YY As String
Dim MM As String


'fileIdx = seldate
fileIdx = VBA.Format(seldate, "yyyymmdd")
YY = Year(Now)
MM = Month(Now)
   'If Val(MM) < 10 Then
     'MM = "0" & MM
   'End If


For a = 1 To 1 '200
    If Range("A" & a).Value <> "" Then
       b = a
       MsgBox b
    End If
Next a

For c = 1 To b
    stockid = Range("A" & c)
    MsgBox stockid
    For d = YY To YY - 1 Step -1
     MsgBox d
        For e = 0 To 11
         If e = MM Then Exit For
           MM1 = MM - e
             'If Val(MM1) < 10 Then
              '  MM1 = "0" & MM1
             'End If
             MsgBox MM1
           
           'Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
           'Set WinHttpReq = CreateObject("MSXML2.XMLHTTP")
           'With WinHttpReq
            '   .Open "GET", myURL, False
             '  .Send
              ' myURL = .responseText
           'End With
          ' Set oStream = CreateObject("ADODB.Stream")
          ' With oStream
           '    .Open
            '   .Type = 1
             '  .Write WinHttpReq.responseBody
              ' fileIdx = ThisWorkbook.Path & "\d" & "MM1" - "stockid" & ".csv"
           '  On Error Resume Next
            '   Kill fileIdx
           '  On Error GoTo 0
            '  .SaveToFile fileIdx
             ' .Close
          ' End With
          ' Set WinHttpReq = Nothing
           'Set oStream = Nothing
        Next e
    Next d
Next c

End Sub



發表於 13-10-17 01:08 | 顯示全部樓層
Sub stock()

Dim seldate As String

或許是這樣吧!
 樓主| 發表於 13-10-17 06:51 | 顯示全部樓層
ju1218 發表於 13-10-17 01:08
Sub stock()

Dim seldate As String

Dear 大大
  改成如下變成型態不符合.....

Sub stock()

Dim seldate As Date
Dim myURL As String
Dim oStream As Object           'ADODB.Stream
Dim WinHttpReq As Object            'XMLHTTP
Dim fileIdx As String
Dim YY As String
Dim MM As String
Dim YY1 As String
Dim a As String
Dim b As String
Dim c As String
Dim d As String
Dim e As String

發表於 13-10-17 19:39 | 顯示全部樓層
Sub stock(seldate As String)............ 這句肯定是錯的

seldate 是個日期 的資料

Sub stock(seldate As DATE)
 樓主| 發表於 13-10-17 20:42 | 顯示全部樓層
本帖最後由 阿俊 於 13-10-17 20:45 編輯
ju1218 發表於 13-10-17 19:39
Sub stock(seldate As String)............ 這句肯定是錯的

seldate 是個日期 的資料

剛才又試了一下,好像是沒存好就執行才會這樣 ju1218 大大說的對,改完後再儲存一次就可以執行了。
感謝大大,不過這一段改好了,接下來的另一段又有問題。可以再請各位大大提供一下寫法嗎??
test.7z (11.66 KB, 下載次數: 303)







錯誤區

錯誤區



您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

手機版|Archiver|站長信箱|廣告洽詢|COCO研究院

GMT+8, 24-4-27 08:00

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 | AI繪圖AI超擬真美女AI beauty AI Stable DiffusionAI正妹AI Lookbook