Sub 批量生成PDF文件test()
'On Error Resume Next
Application.ScreenUpdating = False
Dim pth, pth1, pth2, pth3, fName, pic As String, wd, doc As Object
pth1 = "D:\其他\照片汇总\p3"
pth2 = "张曦,滕峥,房方皓,牟嘉斌,陈泰尧,赵雪,张万菊,林怡,周艳秋,崔晓青,李云逸,匡小舟,王嘉瑜,崔晓娴,王绪琴,董原,刘长河,葛忆琳,郁晓磊,陈敏,沈小明,高烨,曹俊,杨玉颖,刘嘉婧,狄弘玮,王煜垟"
pth3 = "1考绩档案,1考绩档案\2021,1考绩档案\2022,1考绩档案\2023,2学历学位证书,3任职资格证明,4上机上岗材料,5培训进修材料,5培训进修材料\2021,5培训进修材料\2022,5培训进修材料\2023,6发表论文材料,7科研专利材料,8其他"
Set wd = CreateObject("word.application")
Set doc = CreateObject("word.Document")
p2ar = Split(pth2, ",")
p3ar = Split(pth3, ",")
For a = 0 To UBound(p2ar)
For b = 0 To UBound(p3ar)
pth = pth1 & "\" & p2ar(a) & "\" & p3ar(b)
pic = Dir(pth & "*.jpg")
Do While pic <> ""
Set doc = wd.Application.Documents.Add
doc.Selection.InlineShapes.AddPicture Filename:=pth & "\" & pic
doc.ExportAsFixedFormat OutputFileName:= _
"D:\其他\照片汇总\p3\PDF\" & p2ar(a) & "_" & p3ar(b) & ".pdf", ExportFormat:=wdExportFormatPDF
pic = Dir()
Loop
doc.Close False
Next
Next
Set wd = Nothing
Set doc = Nothing
Application.ScreenUpdating = True
End Sub
运行后有如图错误,不知如何设置和修改。请各位老师指点。 |