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

[µo°Ý] ACCESSºô­¶¤W§ì¨ú¸ê®Æ

[µo°Ý] ACCESSºô­¶¤W§ì¨ú¸ê®Æ

¥H¤Uªºµ{¦¡½X¬O¦bª©¤W¬Ý¨ìªº
½Ð°Ý¦U¦ì¤j¤j¦³¥i¯àª½±µ§â¸ê®Æ¦s¤JACCESS¶Ü
·PÁÂ

Sub ²©ö©ú²Ó¤U¸ü()
    Dim ªÑ²¼¥N¸¹ As String, ¤é´Á As Variant, N, i As Integer, A, T As Date
    Do While Not IsDate(¤é´Á)
        ¤é´Á = InputBox("¿é¤J¬d¸ß¤é´Á", "¤é´Á", Date)
        If ¤é´Á = "" Then End
    Loop
    Do While ªÑ²¼¥N¸¹ = ""
        ªÑ²¼¥N¸¹ = InputBox("ªÑ²¼¥N¸¹", "¿é¤J¬d¸ß¤§ªÑ²¼¥N¸¹", "1101")
        If ¤é´Á = "" Then End
    Loop
    ¤é´Á = Format(¤é´Á, "yyyymmdd")
    T = Time
    With ActiveSheet
        For Each N In .Names
            N.Delete
        Next
        .Cells.Clear
        Application.StatusBar = False
        On Error GoTo A_Wait
        i = 1
        Do
            .Cells(Rows.Count, 1).End(xlUp).Offset(1).Select
            With .QueryTables.Add(Connection:="URL;http://bsr.twse.com.tw/bshtm/bshtm_report_Messages.aspx?strDate=" & ¤é´Á & "&StartNumber=" & ªÑ²¼¥N¸¹ & "&FocusIndex=" & i, Destination:=Selection)
                .Name = ¤é´Á & "_" & ªÑ²¼¥N¸¹ & "_" & i
                .WebSelectionType = xlSpecifiedTables
                .WebFormatting = xlWebFormattingNone
                .WebTables = "6"
                .WebPreFormattedTextToColumns = True
                .WebConsecutiveDelimitersAsOne = True
                .WebSingleBlockTextImport = False
                .WebDisableDateRecognition = False
                .WebDisableRedirections = False
              ''''''µLªk¬d¸ß®Éµy«Ý  ¨ì  A_Wait: '''''
                .Refresh BackgroundQuery:=False
                If Application.CountA(.ResultRange) = 0 Then GoTo Out
                i = i + 1
            End With
            A = CreateObject("WScript.Shell").popup("½Ðµ¥«á¤U¸ü..." & Chr(10) & Chr(10) & "** ½Ð¤Å«ö¤U  [½T©w] **", 4, ¤é´Á & "_" & ªÑ²¼¥N¸¹ & "  ²Ä" & i & "­¶", 16 * 3 + 0)
            Application.ScreenUpdating = True
        Loop
Out:
        .UsedRange.Columns.AutoFit
        .[A1].Select
        A = CreateObject("WScript.Shell").popup("¦@¤U¸ü" & i & "­¶", 5, ¤é´Á & "_" & ªÑ²¼¥N¸¹, 48 + 0)
        Application.StatusBar = ªÑ²¼¥N¸¹ & " ¦@¤U¸ü " & i & "­¶ ¶O®É " & Format(Time - T, "HH:MM:SS")
    End With
    End
A_Wait:
    Application.StatusBar = "µLªk¬d¸ßµ¥­Ô5¬íÄÁ"
    Application.Wait Now + TimeValue("00:00:05")
    Err.Clear
    Application.StatusBar = False
    Resume    '­«ªð¬d¸ß
End Sub
jayer

¸É#16ªº¹Ï¡A¦³¹Ï¤~¦³¯u¶H¡I
«Ü©êºp¡A§Ú¬O¤p¾Ç¥Í¡A¤£¯à¤U¸üÀɮסA¬O­Ó¤p§¾«Ä¡I

TOP

¦^´_ 14# 048101
´£¨ÑªºURL¤£Work¡A¸Õ¸Õ§Úªº½d¨Ò¡A¿é¥X¬°html®æ¦¡¡C
¶È°w¹ï2330¥x¿n¹q´ú¸Õ(PageCount=13)¡A¨ä¥LªÑ²¼»Ý³]©wPageCount¡A¥i¤Wºô¬d¤@¤U¤W¥«¶R½æ¤é³øªí¬d¸ß¤U¸üªº¬ÛÃöµ{¦¡§Þ¥©¡C

Option Compare Database
Sub Test()

   Dim MSXML As Object
   Set MSXML = CreateObject("Microsoft.XMLHTTP")
   fh = FreeFile
   'strWebsite = "http://bsr.twse.com.tw/bshtm/bshtm_report_Messages.aspx?strDate=20140227&StartNumber=2330"
   strWebsite = "http://bsr.twse.com.tw/bshtm/bsMenu.aspx?HiddenField_page=PAGE_BS&HiddenField_spDate=&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUKLTQzNzI3ODE3MQ9kFgICAQ9kFhQCBQ8WAh4JaW5uZXJodG1sBQoyMDE0LzAyLzI3ZAIGDxYCHwAFCDIwMTQwMjI3ZAIIDw8WBh4JRm9udF9Cb2xkZx4EXyFTQgKEEB4JRm9yZUNvbG9yCj1kZAIKD2QWBAIBDw9kFgIeB09uQ2xpY2sFHGphdmFzY3JpcHQ6YnV0Q2xlYXJfQ2xpY2soKTtkAgcPFgIeBXN0eWxlBQlkaXNwbGF5OjsWAmYPZBYCZg9kFgICAQ8WAh8ABQIxM2QCDA8PFgYfAWgfAgKEEB8DCkdkZAIODw8WAh4HVmlzaWJsZWhkZAIQDw8WBh8BaB8CAoQQHwMKR2RkAhIPFgIfAGVkAhQPFgIfAGVkAhUPFgIfAAUCMTNkZJhG1J6ISYtK7kIpEfImJdIAAAAA&__EVENTVALIDATION=%2FwEWCQLryNa%2BCwLjpuXcAwKN4Ij0CwLB5ZfoCQLjk6TKBwKY8en5CwLdkpmPAQL6n7vzCwLAhrvLBScjE4xZjzHjsp%2FT1DwVl9MAAAAA&HiddenField_spDate=20140227&HiddenField_page=PAGE_BS&txtTASKNO=2330&hidTASKNO=2330&btnOK=%E6%9F%A5%E8%A9%A2"
   MSXML.Open "POST", strWebsite, False
   strWebsite = "http://bsr.twse.com.tw/bshtm/bsContent.aspx?StartNumber=2330&FocusIndex=All_13"
   MSXML.Open "GET", strWebsite, False
   MSXML.SetRequestHeader "Content-type", "text/xml"
   MSXML.send
   strpageContent = MSXML.responseText
   ' Save html as text/xml
   Open "C:\myStock\AccessVBA-2330.txt" For Output As #FreeFile
   Print #fh, strpageContent
   Set MSXML = Nothing
   Close #fh
   
End Sub
«Ü©êºp¡A§Ú¬O¤p¾Ç¥Í¡A¤£¯à¤U¸üÀɮסA¬O­Ó¤p§¾«Ä¡I

TOP

¥¿¦n¬O§Ú·Q­n§äªº, ·PÁ§AµL¨pªº¤À¨É

TOP

¦bAccess¤¤¥i¥ÎMicrosoft.XMLHTTP¤U¸ü¡M¦p¤U¦C
   Dim MSXML As Object
   Set MSXML = CreateObject("Microsoft.XMLHTTP")
   strWebsite="http://bsr.twse.com.tw/bshtm/bshtm_report_Messages.aspx?strDate=20121203&StartNumber=1101"
   MSXML.Open "GET", strWebsite, False
   MSXML.SetRequestHeader "Content-type", "text/xml"
   MSXML.send

TOP

With .QueryTables.Add(Connection:="URL;http://bsr.twse.com.tw/bshtm/bshtm_report_
¬OÄÝ©óExcel¤U¸ü¬d¸ß¡MAccess¤£¯à¥Î

TOP

¥»©«³Ì«á¥Ñ HSIEN6001 ©ó 2012-5-30 10:48 ½s¿è

¦^´_ 11# losson

ÀɮקR¤F,¨S¯d
¦Ó¥B¨ºÀÉ®×¥u¬O´£¨Ñ·§©À,¦p¥|¼Óªº¹ÏÀÉ,¤À¦¨¨â°Ï¶ô¬d¸ß--->¥H¬Û¦PÄæ¦ì¦WºÙ
¶×¥X¨â­ÓÀɮ׫á,¦A­«·s¶×¤J¤@­Ó·sªí®æ§Y¥i
¨Ï¥ÎªÌ¥²¶·¦Û¦æ¦b¬d¸ß¤¤³]©w¿z¿ï,§âªÅ¥Õor¦h¾lÄæ¦ì¥h±¼

Access¶×¤J:
DoCmd.TransferText acImportDelim, "TEST ¶×¤J³W®æ", "¸ê®ÆªíÀɦW", CurrentProject.Path & "\TEST.txt",True     '¡° True(¦³Äæ¦ì¦WºÙ)False(µLÄæ¦WºÙ)
DoCmd.TransferSpreadsheet acImport, "³W®æ¥N¸¹", "¸ê®ÆªíÀɦW", ¸ô®|\ÀɦW.®æ¦¡, True                                   '¡° True(¦³Äæ¦ì¦WºÙ)False(µLÄæ¦WºÙ)

Access¬d¸ß¶×¥X:
DoCmd.OutputTo acQuery, "¬d¸ßªíÀɦW", 8, "¸ô®|\ÀɦW.xls", False        '¡°  False¶×¥X¬dªí.xls¤£¶}±Ò,True¶×¥X«á¶}±Ò¤å¥ó


¤]¥i¥H¦bExcelªí®æ¤¤¥ý³B²z¦n,¦A¶×¤JAccess

TOP

¦^´_ 5# HSIEN6001
¯à§_¤]±H¤@¥÷µ¹§Ú¡AÅv­­¤£°÷¨S¿ìªk¤U¸ü
³Ìªñ­n¶i¦æ¬ÛÃöªº±Ð¾Ç¡A¥¿¦b­W´o¤¤
ÁÂÁÂ
[email protected]

TOP

½Ð°ÝHSIEN6001

¯à§_¤]±H¤@¥÷ ¨é°Ó²Î­p.rar µ¹§Ú
§Úªº mail : [email protected]
Thanks.

TOP

¥Ø«e¬Ý®Ñ§ä¨ì¤@­Óµ{§Ç
µ{¦¡½X¦p¤U¬O¥i¥HºCºCªº±N¸ê¤JÂà¶i¸ê®Æ®w¸Ì³á
½Ð°Ý¦³¤j¤j¦³§ó¦nªº¤èªk¶Ü


Public Sub °õ¦æSQL±Ô­z()

    Dim cnnDB As New ADODB.Connection '«Ø¥ß¸ê®Æ®w³sµ²ª«¥ó
   
    Set cnnDB = CurrentProject.Connection '¨ú±o¸ê®Æ®w³sµ²
   
    cnnDB.Execute " INSERT INTO ª¿²Îªº½Æ¥» " _
        & "SELECT * " _
        & "FROM [sheet2];"
           
    '°õ¦æSQL±Ô­z
   
    cnnDB.Close 'Ãö³¬¸ê®Æ®w³sµ²
   
    Set cnnDB = Nothing '­«³]¸ê®Æ®w³sµ²
   
End Sub
jayer

TOP

        ÀR«ä¦Û¦b : ¤Hªº¤ß¦a¬O¤@²¥¥Ð¡A¤g¦a¨S¦³¼½¤U¦nºØ¤l¡A¤]ªø¤£¥X¦nªºªG¹ê¡C -
ªð¦^¦Cªí ¤W¤@¥DÃD