Excel 2007/2010 GUI 隐藏工作表查询刷新中的 VBA
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4265237/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VBA in Excel 2007/2010 GUI Hidden Sheet Query Refresh
提问by Richard Perryman-Smalley
Hi First Post and hope someone can help as it is causing hair loss.
嗨,第一篇文章,希望有人能提供帮助,因为它会导致脱发。
I design GUI's using excel and access. 2003 i never had a problem but since updating to 2007/2010 i have having a problem with a seamingly simple thing.
我使用 excel 和 access 设计 GUI。2003 年我从来没有遇到过问题,但是自从更新到 2007/2010 年以来,我遇到了一个非常简单的问题。
In 2003 i could refresh a query on a very hidden sheet using
在 2003 年,我可以使用在非常隐藏的工作表上刷新查询
Sheet2.Range("a1").QueryTable.Refresh BackgroundQuery:=False
in 2007 / 2010 i cannot do this. It works if i cut and paste the query off the 2003 sheets into 2007 / 2010 Perfectly but not if it is a query i build in 2007 / 2010.
在 2007 / 2010 年,我不能这样做。如果我将 2003 年工作表中的查询完美地剪切并粘贴到 2007/2010 年,它会起作用,但如果它是我在 2007/2010 年构建的查询,则不起作用。
The recorder spits out
录音机吐了
Range("Table_Query_from_MS_Access_Database_1[[#Headers],[Trans_ID]]").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Which the page has to be selected first to run
必须首先选择哪个页面才能运行
so logically i have tried
从逻辑上讲,我已经尝试过
Sheet2.Range("a1").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
which selects the position of the query first again wont work it fails at the Sheet2.Range("a1").Select part
它首先再次选择查询的位置不起作用它在 Sheet2.Range("a1").Select 部分失败
Then i logically tried
然后我合乎逻辑地尝试
Sheet2.Range("a1").Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
again this doesnt work
再次这不起作用
Sheet2.Range("Table_Query_from_MS_Access_Database_1[[#Headers],Trans_ID]]") _
.Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
This Also doesnt work
这也不起作用
All i want to do is refresh a query on a very hidden sheet
我想要做的就是在非常隐藏的工作表上刷新查询
Using screen.update = false then unhide macro hide screen update = true isnt really ideal as i want to stop the end user from getting to this query as it is part of a logon System in excel i just cant work out a way to refresh the query on the hidden sheet which was a simple task in 2003.
使用 screen.update = false 然后取消隐藏宏隐藏屏幕更新 = true 并不是很理想,因为我想阻止最终用户访问此查询,因为它是 excel 登录系统的一部分,我只是无法找到一种方法来刷新查询隐藏工作表,这是 2003 年的一项简单任务。
Please help my hair loss
请帮助我的脱发
Thanks
谢谢
Richard
理查德
回答by Charles Williams
Select does not work on a very hidden sheet.
Try it without the select -
Sheet2.Range("a1").ListObject.QueryTable.Refresh BackgroundQuery:=False
Select 在非常隐藏的工作表上不起作用。在没有选择的情况下尝试 -
Sheet2.Range("a1").ListObject.QueryTable.Refresh BackgroundQuery:=False