Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ms access 如何使用SendKeys单击访问报告_Ms Access_Vba_Ms Access 2010 - Fatal编程技术网

Ms access 如何使用SendKeys单击访问报告

Ms access 如何使用SendKeys单击访问报告,ms-access,vba,ms-access-2010,Ms Access,Vba,Ms Access 2010,在为access报告创建了一个目录之后,我终于找到了代码的工作点,并创建了一个目录 作为来自Microsoft州的用户,我需要手动单击打印预览,直到最后一页,以便创建TOC。这很有效 如何使用SendKeys点击访问报告? 这是我到目前为止的代码。。。它工作完美,除了SendKeys什么都不做 'Click through report so that TOC code is executed Dim rptCurReport As Report Set rptCurReport = Scree

在为access报告创建了一个目录之后,我终于找到了代码的工作点,并创建了一个目录

作为来自Microsoft州的用户,我需要手动单击打印预览,直到最后一页,以便创建TOC。这很有效

如何使用SendKeys点击访问报告?

这是我到目前为止的代码。。。它工作完美,除了SendKeys什么都不做

'Click through report so that TOC code is executed
Dim rptCurReport As Report
Set rptCurReport = Screen.ActiveReport

With rptCurReport
    Application.DoCmd.SelectObject acReport, "rptFundSelectionList"
    .Visible = True 'switch to false once code is ok
    'go through all pages
    For i = 1 To .Pages
        SendKeys "{PGDN}", True
    Next i

    'DoCmd.Close acReport, "rptFundSelectionList"
End With

我终于自己解决了这个问题。这是代码。愿它能帮助其他可怜的人

'Open report containing code to create TOC with list of ISINs from above
DoCmd.OpenReport "rptFundSelectionList", acViewPreview, , strWhere
Set dict = Nothing

'Click through report so that TOC code is executed
Dim rptCurReport As Report
Set rptCurReport = Screen.ActiveReport

With rptCurReport
    Application.DoCmd.SelectObject acReport, .Name
    .Visible = True 'switch to false once code is ok
    'go through all pages
    SendKeys "{End}", True
    DoEvents
    Application.DoCmd.SelectObject acReport, .Name
    DoCmd.Close acReport, .Name, acSaveNo
End With

我不熟悉这种特殊情况的方法,但我建议不要使用
SendKeys
。可能存在多个问题。如果运行代码直到
.Visible=True
时,它不执行任何操作,则您的选择不起作用。您的
SendKeys
在页面加载之前可能已经执行了多次,在这种情况下它会起作用,但不会太多。因为手册提到了您必须滚动浏览的原因,我会尝试通过其他方式选择所有记录。我可以运行代码直到
。Visible=True
,如果我将其切换为False,它也会起作用(这也是我如何知道我有正确的焦点).在我打开报告时,有没有关于如何查看记录的建议?我还没有任何这样的例子。好的。因此,使用SendKeys方法产生了一系列完全不同的问题,正如我在这里记录的那样:我试图找到一种不同的方法来逐步查看报告…因此我认为您的方法是正确的。3819867