帮助Excel VBA不保存第二个工作表上的打印设置 [英] Help with Excel VBA not saving print settings on second worksheet

查看:75
本文介绍了帮助Excel VBA不保存第二个工作表上的打印设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个excel程序,设置为创建工作簿,将数据导入2个工作表并重新格式化工作表以进行打印。我需要格式化两个工作表的打印设置,但不保存第二个工作表上的打印设置。当我一步一步地执行该程序时工作正常,但当我关闭工作簿并将其打开时,第二个工作表已丢失其打印设置。我包括整个计划,但第17步是丢失的。我相信它一定是简单的但却不知所措。如果我将工作簿设置为保存但不关闭(在ActiveWorkbook.Save之后停止),然后手动关闭工作簿,它会保存设置,但我需要自动运行。

I have an excel program that is set to create a workbook, import data into 2 worksheets and reformat the sheets for printing. I need to format the print settings for both worksheets but the print settings on the second worksheet are not being saved. The program works fine when I go step by step but when I close the workbook and open it back up, the second worksheet has lost its print settings. I am including the entire program but step 17 is what is being lost. I am sure it must be something simple but am at a loss. If I set the workbook to save but not close (stop after ActiveWorkbook.Save) and then close the workbook manually it does save the settings, but I need this to run automatically.

展开 | 选择 | Wrap | 行号

推荐答案

在发布如此清晰的描述后,真是太遗憾了问题,我无法提供太多的帮助。


我已经检查了你的代码(这也是很好的和明确的评论),但我看不到任何会产生的问题对于你描述的行为。这并不让我感到惊讶,因为你所描述的听起来就像应用程序(Excel)中的那种错误,而不是代码。我无法想象他们会设计一个代码接口来请求在保存工作簿时忽略特定(甚至任何非活动)工作表的设置。如果发生这种情况听起来像Excel本身的问题 - 而不是你的代码。


你可以在第17步之后尝试 DoEvents 语句。您也可以尝试在返回第一个工作表之前在工作簿上执行保存,然后再返回。 Kludgy,但是如果它有效,那么比我预期的要好。


让我们知道你如何继续这些想法。
It''s such a shame that, after posting such a clear description of your problem, I''m unable to give much help.

I''ve checked your code (which is also nice and clear with decent comments) but I see nothing there that would account for the behaviour you describe. This doesn''t surprise me, as what you describe sounds like the sort of error that is within the application (Excel), rather than the code. I can''t imagine they would design a code interface to request that settings for a specific (or even any non-active) worksheet be ignored when saving the workbook. If that''s happening it sounds like a problem with Excel itself - rather than your code.

You could try the DoEvents statement after step #17. You could alternatively try doing a Save on the Workbook before returning to the first Worksheet, then again afterwards. Kludgy, but if it works, then better than not I expect.

Let us know how you get on with these ideas.


谢谢建议。我试过了两次都没有成功。这是令人沮丧的,因为如果我一步一步地工作就行得很好。
Thank you for the suggestions. I tried both and neither was successful. It is frustrating because it works fine if I go step by step.


这样的耻辱。对不起没有什么对你有用。


感兴趣的是,你有什么版本的Windows和Excel?
Such a shame. Sorry nothing worked for you.

As a matter of interest, what are the versions you have for Windows and Excel?


这篇关于帮助Excel VBA不保存第二个工作表上的打印设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆