'生成Word文件,先VBE工具-引用-micorsoft word
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Set wdApp = New Word.Application
Set wdDoc = Documents.Add
Dim mySelection As Word.Selection
Set mySelection = Documents.Application.Selection
Dim MyDesktop As String
MyDesktop = "e:\users\lf\desktop\"
wdDoc.SaveAs MyDesktop & "a2.doc"
wdDoc.Close
With wdApp
.Documents.Open (MyDesktop & "a2.doc")
With .Selection
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Font.Size = 18
.Font.Name = "华文中宋"
.TypeText Text:="关于刘明20万元的调查报告"
.TypeParagraph’插入换行符
.ParagraphFormat.Alignment = wdAlignParagraphLeft
.Font.Size = 14
.Font.Name = "华文仿宋"
.TypeParagraph
.TypeText Text:="区审小组:"
.TypeParagraph
.ParagraphFormat.CharacterUnitFirstLineIndent = 2
.TypeText Text:="接到南阳市公司提交的刘明调查报告后,我部进行了认真的调查,现具体汇报如下:"
.TypeParagraph
.Font.Size = 15
.Font.Name = "黑体"
.TypeText Text:="一、借人基本情况"
.TypeParagraph
.Font.Size = 14
.Font.Name = "华文仿宋"
.TypeText Text:="刘明,男,汉族。"
.TypeParagraph
.TypeParagraph
.TypeText Text:="南阳市**公司"
.ParagraphFormat.Alignment = wdAlignParagraphRight
.ParagraphFormat.RightIndent = CentimetersToPoints(1.95)
.TypeParagraph
.TypeText Text:="2019年11月16日"
.ParagraphFormat.RightIndent = CentimetersToPoints(2.59)
End With
.Documents.Save
End With
wdApp.Visible = True
wdApp.ScreenUpdating = True
wdApp.ActiveWindow.Activate
Set wdDoc = Nothing
Set wdApp = Nothing
Selection.InsertAfter "good" & vbCrLf’在当前光标位置插入该段字符,且插入后该段字符为选中状态。
Selection.TypeParagraph