2,462
社区成员
发帖
与我相关
我的任务
分享
Sub CreateWord()
Dim WordApp As New Word.Application
Dim PageCount As Integer: PageCount = 1
Dim Otable As Object
Dim i As Integer
Dim SaveAsName As String
SaveAsName = ThisWorkbook.Path & "\test.doc"
Dim ICount As Integer: ICount = 1
With WordApp
.Documents.Add
With .Selection
.Font.Size = 24
.Font.Bold = True
.Font.Color = wdColorDarkGreen
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.TypeText Text:="AAAAA"
.TypeParagraph
End With
' <code>:
.ActiveDocument.Tables.Add Range:=.Selection.Range, NumRows:=3, NumColumns:=2
.Selection.Tables(1).Rows.Alignment = wdAlignRowCenter
.Selection.EndKey Unit:=wdStory '这里解决分页问题
.Selection.TypeParagraph
.Selection.InsertBreak Type:=wdPageBreak
.Selection.TypeText Text:="chinaboyzyq(猴哥)"
.Selection.TypeParagraph
.ActiveDocument.Background.Fill.Visible = msoTrue
.ActiveDocument.Background.Fill.ForeColor.RGB = RGB(255, 255, 255)
.ActiveDocument.Background.Fill.Transparency = 0#
.ActiveDocument.Background.Fill.UserPicture "C:\temmp\Images\imgback.jpg"
.ActiveDocument.ActiveWindow.View.DisplayBackgrounds = True '这里解决背景图像显示问题
.ActiveDocument.SaveAs Filename:=SaveAsName
End With
WordApp.Quit '你要让你的word退出。
Set WordApp = Nothing
End Sub