EXCEL VBA 多sheet批量转转PDF

EXCEL VBA 多sheet批量转转PDF

python 复制代码
Sub zhuanpdf()
'转pdf
    Application.ScreenUpdating = False '关闭刷新
    Dim chaifm As String '拆分名
    chaifm = Sheets("参数表").Cells(75, 2).Value
    
    Dim yuanbm As String '原表名
    Dim ws As Worksheet  '定义表格
    Dim biao As String  '表名
    Dim biao2 As String  '辅助记数,有与否
    yuanbm = ActiveSheet.Name
    biao = ""
    biao2 = ""
    On Error Resume Next
    Set ws = Nothing
    '第一个表
        If Sheets("参数表").Cells(5, 2).Value = True And Sheets("参数表").Cells(8, 2).Value <> "" Then
            biao = Sheets("参数表").Cells(8, 2).Value
            Set ws = Sheets(biao)
            If ws Is Nothing Then '指定的工作表不存在
                Else '指定的工作表已存在
                    Sheets(biao).Activate
                    biao2 = biao
                    Set ws = Nothing
            End If
        End If
    '第二个表
        If Sheets("参数表").Cells(6, 2).Value = True And Sheets("参数表").Cells(9, 2).Value <> "" Then
            biao = Sheets("参数表").Cells(9, 2).Value
            Set ws = Sheets(biao)
            If ws Is Nothing Then '指定的工作表不存在
                Else '指定的工作表已存在
                    If biao2 = "" Then
                        Sheets(biao).Activate
                        Else
                            Sheets(biao).Select Replace:=False
                    End If
                    biao2 = biao
                    Set ws = Nothing
            End If
        End If
    '第三个表
        If Sheets("参数表").Cells(7, 2).Value = True And Sheets("参数表").Cells(10, 2).Value <> "" Then
            Dim biaochuan As String '表串,即多个工作表,用"/"分开
            Dim iii As Integer
            biaochuan = Sheets("参数表").Cells(10, 2).Value
            iii = 1
            Do While iii <> 100
                iii = InStr(1, biaochuan, "/", 0)
                If iii = 0 Then
                    iii = 100
                    biao = biaochuan
                    Else
                        biao = Left(biaochuan, iii - 1)
                        biaochuan = Mid(biaochuan, iii + 1, 300)
                End If
                Set ws = Sheets(biao)
                If ws Is Nothing Then '指定的工作表不存在
                    Else '指定的工作表已存在
                        If biao2 = "" Then
                            Sheets(biao).Activate
                            Else
                                Sheets(biao).Select Replace:=False
                        End If
                        biao2 = biao
                        Set ws = Nothing
                End If
            Loop
        End If
    '生成pdf
        Call zhuanpdf2(chaifm)
On Error GoTo 0
Sheets(yuanbm).Select
Application.ScreenUpdating = True '开启刷新
    
End Sub
Sub zhuanpdf2(chaifm As String)
'转pdf2
    luj = ThisWorkbook.Path
    If Dir(luj & "\拆分表", vbDirectory) = Empty Then
        MkDir luj & "\拆分表"
    End If
    luj = luj & "\拆分表\"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
            luj & chaifm & ".pdf", Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
            False
End Sub
相关推荐
Lauren_Lu8 小时前
pdf 不是扫描件,但却无法搜索关键词【问题尝试解决未果记录】
pdf
河山入梦来13 小时前
Excel表的导入与导出
excel
Python猫18 小时前
付费专栏·Python潮流周刊电子书合集(epub、pdf、markdown)下载
python·计算机·pdf·电子书·资料
JackieZhengChina19 小时前
用python清除PDF文件中的水印(Adobe Acrobat 无法删除)
pdf
wtsolutions1 天前
Excel-to-JSON插件专业版功能详解:让Excel数据转换更灵活
json·excel·excel-to-json·wtsolutions·专业版
梦幻通灵1 天前
Excel分组计算求和的两种实现方案
前端·excel
geovindu1 天前
vue3: pdf.js 3.4.120 using javascript
开发语言·javascript·vue.js·pdf
莫负初1 天前
Excel使用VBA批量计算指定列的中位数和标准差并筛选指定列数据
数据分析·自动化·excel·vba·方差·标准差
TextIn智能文档云平台1 天前
PDF文档解析新突破:图表识别、公式还原、手写字体处理,让AI真正读懂复杂文档!
图像处理·人工智能·算法·自然语言处理·pdf·ocr
old_power1 天前
【Python】PDF文件处理(PyPDF2、borb、fitz)
python·pdf