Ms access 使用MS Access进行慢速下载

Ms access 使用MS Access进行慢速下载,ms-access,download,vba,ms-office,Ms Access,Download,Vba,Ms Office,我有一个子系统可以打开excel,创建到我的google工作表的连接,然后使用insert语句将数据添加到我的Access数据库中。 这可以工作,但速度非常慢(需要约30秒才能获得6条记录) 使用Debug.Print查看哪些部分实际花费了这么长的时间 Timer是Access中的函数,不要将其用作变量名 等待循环必须有Sleep调用和DoEvents调用,以避免占用CPU Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal

我有一个子系统可以打开excel,创建到我的google工作表的连接,然后使用insert语句将数据添加到我的Access数据库中。
这可以工作,但速度非常慢(需要约30秒才能获得6条记录)


使用
Debug.Print
查看哪些部分实际花费了这么长的时间

Timer
是Access中的函数,不要将其用作变量名

等待循环必须有
Sleep
调用和
DoEvents
调用,以避免占用CPU

Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

'Wait for google-doc data to be downloaded.
lTimer = 0
Do While Left(wst.cells(1, 1), 12) = "ExternalData" And lTimer < 40
    Debug.Print "Wait loop " & lTimer    ' Ctrl+g shows output
    Sleep 250 ' Wait 0.25 sec before re-checking data
    DoEvents
    lTimer = lTimer + 1
Loop
Private声明子睡眠库“kernel32”别名“Sleep”(ByVal-dwms长度)
'等待下载google文档数据。
lTimer=0
左移时执行(wst.单元格(1,1),12)=“外部数据”和lTimer<40
调试。打印“等待循环”&lTimer的Ctrl+g显示输出
休眠250'等待0.25秒,然后重新检查数据
多芬特
lTimer=lTimer+1
环

如果这没有帮助,你可能不得不接受它。

发现另一个问题,只有100条记录被下载,解决方案也解决了速度问题

我找到了解决办法

它说您需要更改链接的格式,从



这会将其从可编辑视图更改为更基本的视图

您是否尝试对不同的部分计时?完成下载和执行插入需要多长时间?不完全是这样,但我在插入循环之前设置了一个断点,几乎所有的等待都发生在该断点之前,所以问题似乎是来自Google的web fetch:很难说如何加快速度。
Debug.Print "before wait while " & Now
'Wait for google-doc data to be downloaded.
lTimer = 0
Do While Left(wst.cells(1, 1), 12) = "ExternalData" And lTimer < 40
    Debug.Print "Wait loop " & lTimer 
    Debug.Print "during wait while " & Now
    Sleep 250 ' Wait 0.25 sec before re-checking data
    DoEvents
    lTimer = lTimer + 1
Loop

Debug.Print "after wait while" & Now
start time 18/07/2017 9:06:58 a.m.
before connect 18/07/2017 9:06:58 a.m.
before wait while 18/07/2017 9:07:00 a.m.
Wait loop 0
during wait while 18/07/2017 9:07:00 a.m.
Wait loop 1
during wait while 18/07/2017 9:07:00 a.m.
Wait loop 2
during wait while 18/07/2017 9:07:01 a.m.
Wait loop 3
during wait while 18/07/2017 9:07:01 a.m.
Wait loop 4
during wait while 18/07/2017 9:07:01 a.m.
Wait loop 5
during wait while 18/07/2017 9:07:01 a.m.
Wait loop 6
during wait while 18/07/2017 9:07:02 a.m.
Wait loop 7
during wait while 18/07/2017 9:07:02 a.m.
Wait loop 8
during wait while 18/07/2017 9:07:02 a.m.
Wait loop 9
during wait while 18/07/2017 9:07:02 a.m.
Wait loop 10
during wait while 18/07/2017 9:07:03 a.m.
Wait loop 11
during wait while 18/07/2017 9:07:03 a.m.
after wait while 18/07/2017 9:07:28 a.m.
Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

'Wait for google-doc data to be downloaded.
lTimer = 0
Do While Left(wst.cells(1, 1), 12) = "ExternalData" And lTimer < 40
    Debug.Print "Wait loop " & lTimer    ' Ctrl+g shows output
    Sleep 250 ' Wait 0.25 sec before re-checking data
    DoEvents
    lTimer = lTimer + 1
Loop