无法添加到ActiveWindow.SelectedWorksheets [英] Unable to add to ActiveWindow.SelectedWorksheets
问题描述
我正在使用代码
Worksheet.Select Replace:=False
它不会添加到 ActiveWindow.SelectedWorksheets
以下内容并非在所有环境中都适用.
The following does not work in all environments.
For i = 2 To ActiveWorkbook.Worksheets.Count
ActiveWorkbook.Worksheets(i).Select Replace:=False
Next i
ActiveWindow.SelectedSheets.PrintPreview
打印预览仅显示一页(第一张/活动页).如果我请求Count,它也为1,但我得到的工作表则多于1(实际上多于10 )
The print preview only shows 1 page (first/active sheet). If I request the Count, its also 1, but I got more then 1 worksheet (actually more then 10)
它看起来确实与Windows更新有关(因为用户突然体验了它,而对宏没有任何更改).
It does look like it has something to do with a windows update (since user experience it suddenly without any change to the macro).
最近有没有人遇到相同的问题?
Does anyone expiriance the same issue lately?
如何解决此问题?
推荐答案
一个用户的工作簿报告了一个问题,但是直到我安装了最新更新后,该问题才出现在我的计算机上.看来问题出在Replace:= False.原稿在下面.
A problem was reported by one of our workbooks by a user but did not show up on my machine until after I installed the most recent update. It appeared the problem was with the Replace:=False. Original is below.
Worksheets("Proposal").Select Replace:=False
Worksheets("Terms").Select Replace:=False
Worksheets("Soft Maint").Select Replace:=False
Worksheets("Emerg Servi").Select Replace:=False
Worksheets("Spl Prov").Select Replace:=False
Worksheets("Equip List").Select Replace:=False
If Application.Sum(Worksheets("Quote Info").Range("B23")) = 1 Then Sheets("FA T&I").Select Replace:=False
If Application.Sum(Worksheets("Quote Info").Range("B23")) = 2 Then Sheets("FA T&M").Select Replace:=False
经过多次尝试,我想到了这一点,并且奏效了.不知道为什么,但是我不是抽屉里最锋利的刀.我只更改了前几行,但认为如果有帮助,我会跳过整个内容.
After many tries I came up with this and it worked. Not sure why but I am not the sharpest knife in the drawer. I only changed the first few lines but figured I would past the entire thing in case it helps.
Sheets(Array("Proposal", "Terms", "Soft Maint", "Emerg Servi", "Spl Prov", "Equip List")). _
Select Replace:=False
If Application.Sum(Worksheets("Quote Info").Range("B23")) = 1 Then Sheets("FA T&I").Select Replace:=False
If Application.Sum(Worksheets("Quote Info").Range("B23")) = 2 Then Sheets("FA T&M").Select Replace:=False
希望这会有所帮助
这篇关于无法添加到ActiveWindow.SelectedWorksheets的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!