excel - 使用复选框从excel中获取多个pdf
问题描述
我的挑战是使用 checkbos 导出多个 excel 表。我已经完成了如下脚本,但它仅在选中一个复选框时才有效。行“阵列(tuloste)。选择两个复选框时,选择”是错误的。
Private Sub CommandButton1_Click()
Dim nimi
Dim tarjousnumero
Dim polku
Dim sivut As String
Dim Liite1
Dim Liite2
If CheckBox1.Value = True Then
Liite1 = "Palvelukuvaus"
Else
Liite1 = ""
End If
If CheckBox2.Value = True Then
Liite2 = "Etävalvonta"
Else
Liite2 = ""
End If
tuloste = Liite1 & Liite2
ActiveWorkbook.Save
Range("I2").Activate
tarjousnumero = ActiveCell
nimi = InputBox("Anna tiedoston nimi", "Tallenna pdf muodossa", "Tarjous " & tarjousnumero)
polku = ActiveWorkbook.Path
Sheets("Kaupallinen tarjous").Select
Sheets(Array(tuloste)).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=polku & "\" & nimi & ".pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _OpenAfterPublish:=False
Sheets("Kaupallinen tarjous").Select
UserForm2.Hide
End Sub
解决方案
对不起——下面少了外来词。我想制作一个 pdf_printout,它有一个固定的工作表(Kaupallinen tarjous)和我可以通过 chackboxes 选择的附件。此时最终的 pdf_printout 可以有 0 - 2 个附件。它可能会变成更多的复选框来选择,所以更多的动态代码也将不胜感激。但是现在我可以有 0 - 2 个附件。我通过使用 if 条件解决了打印输出具有“”值的问题,但仍然难以选择两个复选框。
Private Sub CommandButton1_Click()
Dim file
Dim offernumber
Dim path
Dim pages As String
Dim printout As String
Dim Appendix1 As String
Dim Appendix2 As String
If CheckBox1.Value = True Then
Appendix1 = "Our services"
Else
Appendix1 = ""
End If
If CheckBox2.Value = True Then
Appendix2 = "Remote control"
Else
Appendix2 = ""
End If
printout = Appendix1 & Appendix2
ActiveWorkbook.Save
Range("I2").Activate
offernumber = ActiveCell
file = InputBox("Anna tiedoston file", "Tallenna pdf muodossa", "Tarjous " &
offernumber)
path = ActiveWorkbook.Path
Sheets("Kaupallinen tarjous").Select
if printout="" then
Sheets(“Kaupallinen tarjous”).Select
else
Sheets(array(“Kaupallinen tarjous”, printout)).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=path & "\" & file & ".pdf",
Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Sheets("Kaupallinen tarjous").Select
UserForm2.Hide
End Sub
推荐阅读
- sapui5 - 使用 npm 安装 OpenUI5 工具失败
- rust-cargo - 注意:/usr/bin/ld: 找不到 -lpq Rust
- go - 无效的 golang 配置文件输出格式
- python - 在循环python中将deltatime添加到每个日期
- go - 在没有泛型的情况下在 Golang 中重用类似的代码
- python - AttributeError:模块“tensorflow_core._api.v2.image”没有属性“resize_images”
- apache-camel - Apache Camel:创建多个路线是否成本高昂?
- ruby-on-rails - “错误”:“参数数量错误(给定 1,预期为 0)”
- kubernetes - Kubernetes 如何计算 HPA 的 CPU 利用率?
- c++ - 如何在通过`cin`从键盘提取的流中打印`[`和`,`和`]`