VB6生成Word文件

'生成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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值