|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub my()
Dim appWD, doc As Object, f, arr, i, j, r
arr = Sheet1.[b4].CurrentRegion
Set appWD = CreateObject("Word.Application")
f = ThisWorkbook.Path & "\劳动合同范本.doc"
For i = 2 To UBound(arr)
Set doc = appWD.Documents.Open(f)
appWD.Visible = 0
For j = 1 To UBound(arr, 2)
r = appWD.ActiveDocument.Content.Bookmarks(j).End
If j = 8 Then
appWD.ActiveDocument.Range(r, r).InsertAfter Format(arr(i, j), "yyyy年mm月dd")
Else
appWD.ActiveDocument.Range(r, r).InsertAfter arr(i, j)
End If
appWD.ActiveDocument.Range(r, r + Len(arr(i, j))).Font.Underline = 2
Next
doc.SaveAs ThisWorkbook.Path & "\" & "劳动合同-" & arr(i, 2) & ".doc"
doc.Close
Next
appWD.Quit
End Sub |
评分
-
2
查看全部评分
-
|