利用VBA打印隐藏的excel工作表
时间:2022-11-19 12:33:00
如果一个工作簿中包含许多工作表,其中还有一些是隐藏的,我们可以用VBA代码来直接打印所有隐藏的工作表,而无需将它们取消隐藏。由于Excel无法打印隐藏的工作表,下面的代码先取消工作表的隐藏,打印之后再将其隐藏起来。将代码放入VBA编辑器的标准模块中运行。
Sub PrintHiddenSheets()
Dim wSheet As Worksheet
Dim CurStat As Variant
For Each wSheet In ActiveWorkbook.Worksheets
If Not wSheet.Visible Then
CurStat = wSheet.Visible
wSheet.Visible = xlSheetVisible
‘打印预览,如果要打印用 wSheet.PrintOut
wSheet.PrintPreview
wSheet.Visible = CurStat
End If
Next
End Sub
标签:代码,工作,打印,隐藏,Excel函数
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
把Excel2010中多余的单元格隐藏起来
2023-02-03 00:32:07
![](https://img.aspxhome.com/file/2023/5/38485_0s.jpg)
Word表格转Excel格式大变样?学会这一招,轻松搞定
2023-01-03 16:08:12
![](https://img.aspxhome.com/file/2023/9/35199_0s.png)
如何取消在Word 2007和2010中创建的"书法字帖"文件默认是保护状态
2023-12-13 12:49:45
在word中添加背景音乐?
2023-12-08 10:53:14
在数据格式窗口选择XY对儿
2023-05-03 01:56:08
Word怎么添加页码
2022-07-14 22:12:11
![](https://img.aspxhome.com/file/2023/2/34422_0s.gif)
Win10夜间模式失效怎么办?Win10夜间模式出现Bug怎么办?
2023-05-25 19:12:56
![](https://img.aspxhome.com/file/2023/5/52135_0s.jpg)
在word或wps中怎样分栏
2023-11-29 21:33:35
![](https://img.aspxhome.com/file/2023/0/18610_0s.jpg)
Win10 20H2系统如何查看系统属性?
2023-11-23 04:13:13
![](https://img.aspxhome.com/file/2023/3/50493_0s.png)
iOS 15 正式版存在的 Bug 汇总
2023-08-16 11:55:41
![](https://img.aspxhome.com/file/2023/8/45638_0s.png)
Excel公式返回#NAME?错误值原因及解决方法
2023-10-22 01:24:31
excel的剪切复制粘贴快捷键使用
2022-08-02 07:30:21
microsoft excel设置打印区域的方法
2023-05-11 16:04:30
word怎么删除文字的底色呢?
2022-12-29 08:43:12
![](https://img.aspxhome.com/file/2023/9/24009_0s.jpg)
怎么把xls格式的excel表格转换成csv格式?
2022-02-14 14:58:31
![](https://img.aspxhome.com/file/2023/6/42576_0s.jpg)
excel两表格内容关联的方法
2023-10-31 04:14:18
Win10怎么打开系统摄像头?Win10打开系统摄像头方法
2022-01-20 01:28:39
![](https://img.aspxhome.com/file/2023/9/52909_0s.png)
excel两个表格数据关联的方法
2023-09-14 07:55:43
Excel2010如何手动批量求和
2022-11-27 07:19:52
![](https://img.aspxhome.com/file/2023/2/37212_0s.jpg)
Word中如何输入对钩?Word2007对钩输入方法分享
2022-05-30 09:09:30
![](https://img.aspxhome.com/file/2023/4/31454_0s.jpg)