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
相关推荐
开开心心_Every12 小时前
安卓图片压缩工具,无损缩放尺寸免费好用
人工智能·pdf·计算机外设·ocr·语音识别·团队开发·规格说明书
无心水13 小时前
14、企业级表格|AWS Textract 扫描件表格自动结构化
架构·pdf·云计算·aws·pdf解析·pdf抽取·aws textract
开开心心就好14 小时前
系统重装前必备的智能驱动备份工具
windows·计算机视觉·计算机外设·excel·模块测试·csdn开发云·威胁分析
无心水16 小时前
13、云端OCR终极指南|百度/阿里/腾讯API高精度文字提取实战
百度·架构·pdf·ocr·dubbo·pdf解析·pdf抽取
向宇it1 天前
php高性能的导出excel读写扩展——xlswriter,比传统的Spreadsheet要快很多
php·excel·xlswriter
yanweijie03171 天前
对比VLOOKUP、XLOOKUP、INDEX+MATCH三大查找函数
excel
优化控制仿真模型1 天前
2026年初中英语大纲词汇表1600词
经验分享·pdf
优化控制仿真模型1 天前
方正小标宋简体、仿宋GB2312和楷体_GB2312办公字体安装包下载安装教程
经验分享·pdf
Codiggerworld1 天前
Vim的语法:删除、复制、粘贴,像说话一样自然
编辑器·vim·excel
王莎莎-MinerU1 天前
MinerU 生态全景:Skills、RAG、MCP、Cursor Rules
人工智能·深度学习·计算机视觉·chatgpt·pdf·软件工程