|
用EXCEL表中的VBA生成Word文档,程序自己摸出来了,但是粘贴到WORD后原内容超出边界了。能不能直接生成WORD时就把格式调整好。上下左右页边距分别为1,1,0.75,0.75。并且WORD表格内容可以完整的显示出来。感谢帮忙!
Sub 生成WORD文档()
Dim rng As Range
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set rng = ActiveSheet.UsedRange
With CreateObject("Word.Application")
.Visible = False
.Documents.Add
rng.Copy
.Selection.PasteExcelTable False, False, False
.ActiveDocument.SaveAs Filename:=Replace(ThisWorkbook.FullName, "xls", "doc")
.ActiveDocument.Close
.Quit
End With
Application.CutCopyMode = False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "订单已生成!"
End Sub
|
|