保存.PDF版本时不包括指定的工作表 [英] Excluding specified sheets when saving the .PDF version

查看:36
本文介绍了保存.PDF版本时不包括指定的工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在工作簿中隐藏指定的工作表,因为我不希望将它们保存在我的.PDF版本中.

基于

解决方案

请尝试以下这段代码:

  Sub SplicingAsbuilt()Dim Sh作为工作表,arrSh作为变体,arr作为变体arrSh = Array(材料-规格",防火",中继",落差计算器",_"BoM","BoQ Civils","BoQ Cabling")对于ThisWorkbook.Sheets中的每个Sh如果Sh.Name像"* Civils *",则Sh.Visible = xlSheetHidden对于arrSh中的每个arr如果Sh.Name = arr,则Sh.Visible = xlSheetHidden:退出下一个下一个结束子 

I would like to hide specified sheets in my workbook, because I don't want them to be saved in my .PDF version.

Based on How to exclude 1 sheet from my save to pdf VBA macro I specified sheet names, however I have a group of sheets, which can be expanded (Civils 1, Civils 2 exist, but the Civils 3 and so on may appear).

I prepared code:

Sub SplicingAsbuilt()
  Sheets(Array("Materials - Specifications", "Fire Stopping", "Trunking", "Drop Length Calculator", 
  "BoM", "BoQ Civils", "BoQ Cabling")).Visible = False
  If ThisWorkbook.Sheets.Name Like "*Civils*" Then
    Sheets.Visible = False
  End If

My console returns:

"Method or data member not found"

An example of the answer presented here: Excel VBA: Compile Error: Method or data member not found doesn't apply.

解决方案

Try this piece of code, please:

Sub SplicingAsbuilt()
 Dim Sh As Worksheet, arrSh As Variant, arr As Variant
  arrSh = Array("Materials - Specifications", "Fire Stopping", "Trunking", "Drop Length Calculator", _
  "BoM", "BoQ Civils", "BoQ Cabling")

  For Each Sh In ThisWorkbook.Sheets
    If Sh.Name Like "*Civils*" Then Sh.Visible = xlSheetHidden
    For Each arr In arrSh
       If Sh.Name = arr Then Sh.Visible = xlSheetHidden: Exit For
    Next
  Next
End Sub

这篇关于保存.PDF版本时不包括指定的工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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