|
Sub test()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim wdApp As Object
Set wdApp = CreateObject("Word.Application") '新建Word对象
wdApp.Visible = True
With ActiveSheet
r = .Cells(Rows.Count, 1).End(xlUp).Row
ar = .Range("a1:f" & r)
End With
lj = ThisWorkbook.Path
mb = lj & "\文档.docx"
If Dir(mb) = "" Then MsgBox "找不到文档!": End
t = Timer
Set wdd = wdApp.Documents.Open(mb)
For i = 2 To UBound(ar)
If Len(Trim(ar(i, 1))) > 0 Then
m = m + 1
zf = ""
If ar(i, 5) <> "" Then
zf = ar(i, 5)
End If
If ar(i, 6) <> "" Then
If zf = "" Then
zf = ar(i, 6)
Else
zf = zf & "," & ar(i, 6)
End If
End If
zd = ar(i, 1) & "," & Format(ar(i, 2), "yyyy年m月d日") & "出生," & ar(i, 3) & ",毕业于" & ar(i, 4) & "获得" & zf
With wdApp.Selection
.Font.Size = 14
.EndKey 'Unit:=wdStory '光标置于文件尾
.Text = "个人简历" & m & Chr(10) & zd
'.EndKey 'Unit:=wdStory '光标置于文件尾
'.Text = zd
f = Dir(lj & "\证书荣誉\*.*g")
k = 0
Do While f <> ""
If InStr(f, ar(i, 1)) > 0 Then
k = k + 1
tt = lj & "\证书荣誉\" & f
.EndKey 'Unit:=wdStory '光标置于文件尾
.InlineShapes.AddPicture Filename:=tt, LinkToFile:=False, SaveWithDocument:=True '直接插入
'wdd.InlineShapes(k).Height = 535 '调整图片高度
End If
f = Dir
Loop
End With
Set f = Nothing
End If
Next i
wdd.SaveAs Filename:=lj & "\文档" & Format(Date, "yyyymmdd") & ".docx"
wdd.Close
Set wdd = Nothing
Set wdApp = Nothing
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "耗时:" & Format(Timer - t, "0.00") & "秒"
End Sub
|
评分
-
1
查看全部评分
-
|