VB将数据导出到word的问题
把label1的内容输出到word的第一行,设置居中,加粗,16号字text1和text2中内容输出到第二行,设置左对齐,不加粗,10号字mshflexgrid的内容输出...
把label1的内容输出到word的第一行,设置居中,加粗,16号字
text1和text2中内容输出到第二行,设置左对齐,不加粗,10号字
mshflexgrid的内容输出到第三行,要新建一个mshflexgrid1.rows行,10列的表格,然后把mshflexgrid1的内容填进去
text3和text4的内容输出到表格后面的那行,两个内容间隔为3个tab键,10号字,不加粗,左对齐,红色
text5和text6的内容输出到下面一行,两个内容间隔为3个tab键,10号字,不加粗,左对齐,黑色
求详细代码,谢谢! 展开
text1和text2中内容输出到第二行,设置左对齐,不加粗,10号字
mshflexgrid的内容输出到第三行,要新建一个mshflexgrid1.rows行,10列的表格,然后把mshflexgrid1的内容填进去
text3和text4的内容输出到表格后面的那行,两个内容间隔为3个tab键,10号字,不加粗,左对齐,红色
text5和text6的内容输出到下面一行,两个内容间隔为3个tab键,10号字,不加粗,左对齐,黑色
求详细代码,谢谢! 展开
1个回答
展开全部
Private Sub Command1_Click()
Dim wd As New Word.Application
wd.Documents.Add DocumentType:=wdNewBlankDocument
With wd.Selection
.Font.Spacing = 2
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Font.Size = 16
.Font.Name = "宋体"
.Font.Bold = True
.ParagraphFormat.LineSpacingRule = wdLineSpaceSingle
.Font.Spacing = 0
.TypeText label1.Caption
.Font.Bold = False
.TypeParagraph
.ParagraphFormat.Alignment = wdAlignParagraphJustify
.Font.Size = 10
.TypeText text1.Text & text2.Text
wd.ActiveDocument.Tables.Add Range:=wd.Selection.Range, NumRows:=mshflexgrid1.Rows, NumColumns _
:=10, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed
For i = 1 To mshflexgrid1.Rows
For j = 1 To 10
.Tables(1).Cell(i, j).Range.Text = mshflexgrid1.textmatrix(i - 1, j - 1)
Next j
Next i
.EndKey Unit:=wdStory
.Font.Color = wdColorRed
.TypeText text3.Text & vbTab & vbTab & vbTab & text4.Text
.TypeParagraph
.Font.Color = wdColorAutomatic
.TypeText text5.Text & vbTab & vbTab & vbTab & text6.Text
End With
wd.Visible = True
wd.ShowMe
Set wd = Nothing
End Sub
Dim wd As New Word.Application
wd.Documents.Add DocumentType:=wdNewBlankDocument
With wd.Selection
.Font.Spacing = 2
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Font.Size = 16
.Font.Name = "宋体"
.Font.Bold = True
.ParagraphFormat.LineSpacingRule = wdLineSpaceSingle
.Font.Spacing = 0
.TypeText label1.Caption
.Font.Bold = False
.TypeParagraph
.ParagraphFormat.Alignment = wdAlignParagraphJustify
.Font.Size = 10
.TypeText text1.Text & text2.Text
wd.ActiveDocument.Tables.Add Range:=wd.Selection.Range, NumRows:=mshflexgrid1.Rows, NumColumns _
:=10, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed
For i = 1 To mshflexgrid1.Rows
For j = 1 To 10
.Tables(1).Cell(i, j).Range.Text = mshflexgrid1.textmatrix(i - 1, j - 1)
Next j
Next i
.EndKey Unit:=wdStory
.Font.Color = wdColorRed
.TypeText text3.Text & vbTab & vbTab & vbTab & text4.Text
.TypeParagraph
.Font.Color = wdColorAutomatic
.TypeText text5.Text & vbTab & vbTab & vbTab & text6.Text
End With
wd.Visible = True
wd.ShowMe
Set wd = Nothing
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询