在为我的访问报告创建目录之后,我终于找到了代码工作的地方,并创建了一个目录。
作为Microsoft州的instructions,我需要手动点击“打印预览”直到最后一页,以便创建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
答案 0 :(得分:1)
我已经成功地为自己解决了这个问题。这是代码。愿它帮助其他一些可怜的灵魂!
'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