|
老师,我将excel里的文本内容插入到指定word的页脚处,插入完毕后,打印这个word,目前发现,插入页脚成功后,word处于页眉页脚编辑状态,所以页眉处会有一条横线,如果关闭页眉页脚编辑模式,页眉的横线就没有了,想问下怎么样关闭页眉页脚编辑状态,谢谢,就是这句wordobj.sections(1).footers(1).Range.Text = y以后应该加什么代码?
Sub 打印()
Dim arr, irow%, Spath, i%, Sname$, x As Byte, y As String
Dim wordapp As Object, wordobj As Object
Set wordapp = CreateObject("word.application")
wordapp.Visible = True
Spath = ThisWorkbook.Path & "\doc\"
irow = Sheet1.[a65536].End(xlUp).Row
arr = Range("a1:a" & irow)
For i = 2 To UBound(arr)
x = Range("b" & i).Value
y = Range("c" & i).Value
Sname = Dir(Spath & arr(i, 1) & "*.*")
Set wordobj = wordapp.documents.Open(Spath & Sname)
Sub 打印()
Dim arr, irow%, Spath, i%, Sname$, x As Byte, y As String
Dim wordapp As Object, wordobj As Object
Set wordapp = CreateObject("word.application")
wordapp.Visible = True
Spath = ThisWorkbook.Path & "\doc\"
irow = Sheet1.[a65536].End(xlUp).Row
arr = Range("a1:a" & irow)
For i = 2 To UBound(arr)
x = Range("b" & i).Value
y = Range("c" & i).Value
Sname = Dir(Spath & arr(i, 1) & "*.*")
Set wordobj = wordapp.documents.Open(Spath & Sname)
wordobj.sections(1).footers(1).Range.Text = y
wordobj.PrintOut copies:=CStr(x)
wordobj.Close
On Error Resume Next
Next
End Sub
|
|