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
相关推荐
沉到海底去吧Go7 小时前
【行驶证识别成表格】批量OCR行驶证识别与Excel自动化处理系统,行驶证扫描件和照片图片识别后保存为Excel表格,基于QT和华为ocr识别的实现教程
自动化·ocr·excel·行驶证识别·行驶证识别表格·批量行驶证读取表格
漫游者Nova14 小时前
PDF转Markdown/JSON软件MinerU最新1.3.12版整合包下载
pdf·json·markdown·mineru
sss191s18 小时前
Java 集合面试题 PDF 及常见考点解析与备考指南
java·开发语言·pdf
风筝超冷20 小时前
PDF 转 Markdown
pdf
wxgnolux20 小时前
网页端 js 读取发票里的二维码信息(图片和PDF格式)
pdf·jsqr
Eiceblue20 小时前
C# 快速检测 PDF 是否加密,并验证正确密码
开发语言·pdf·c#·visual studio
耗不尽的先生20 小时前
【PDF PicKiller】PDF批量删除固定位置图片工具,默认解密,可去一般图、背景图、水印图!
pdf
Abigail_chow1 天前
EXCEL如何快速批量给两字姓名中间加空格
windows·microsoft·excel·学习方法·政务
weixin_472339461 天前
使用Python提取PDF元数据的完整指南
java·python·pdf
前端探险家1 天前
vue2中使用jspdf插件实现页面自定义块pdf下载
pdf