Dim WPS_App As WPS.Application
Dim WPS_Doc As WPS.Document
Dim P As WPS.Paragraph
Dim I As Integer
Private Sub Command1_Click()
'启动WPS应用程序
Set WPS_App = CreateObject("wps.application")
'程序可见最大化
WPS_App.Visible = True
WPS_App.WindowState = wpsWindowStateMaximize
'新建文档
Set WPS_Doc = WPS_App.Documents.Add()
'设置页边距
With WPS_Doc.PageSetup
.PageHeight = CentimetersToPoints(59.4)
.PageWidth = CentimetersToPoints(21#)
.TopMargin = CentimetersToPoints(2.5)
.BottomMargin = CentimetersToPoints(2#)
.LeftMargin = CentimetersToPoints(2#)
.RightMargin = CentimetersToPoints(1.5)
End With
With WPS_Doc
Set P = .Paragraphs.Add
I = .Paragraphs.Count
P.Range.Font.Name = "黑体"
P.Range.Font.Size = 15
P.Alignment = wpsAlignParagraphCenter
P.Range.Text = "黑体 15 居中对齐" & vbLf
Set P = .Paragraphs.Add
I = .Paragraphs.Count
P.Range.Font.Name = "宋体"
P.Range.Font.Size = 15
P.Alignment = wpsAlignParagraphCenter
P.Range.Text = "插入3行5列表格"
'插入3行5列表格
Set P = .Paragraphs.Add
I = .Paragraphs.Count
P.Alignment = wpsAlignParagraphLeft
.Tables.Add .Range(.Range.End - 1, .Range.End), 3, 5, , wpsAutoFitFixed
With .Tables(1)
.Cell(2, 3).Range.Font.Name = "楷体"
.Cell(2, 3).Range.Font.Size = 10
.Cell(2, 3).Range.Text = "第二行,第三列"
.Cell(2, 3).Borders(wpsBorderRight).Color = wpsColorLightYellow
.Columns.Width = 100
.Rows.Height = 20
End With
Set P = .Paragraphs.Add
I = .Paragraphs.Count
P.Range.Font.Name = "隶书"
P.Range.Font.Size = 15
P.Range.Font.Color = wpsColorRed
P.Alignment = wpsAlignParagraphLeft
P.LineSpacing = 50 '行距
P.Range.Text = "段落3 隶书 字体大小15 居左,行距50,颜色红色" & vbLf
Set P = .Paragraphs.Add
I = .Paragraphs.Count
P.Range.Font.Name = "黑体"
P.Range.Font.Size = 15
P.Alignment = wpsAlignParagraphCenter
P.LineSpacing = 10 '行距
P.Range.Text = "段落4 插入图片" & vbLf
'嵌入图像
P.Range.InlineShapes.AddPicture App.Path & "/blog_logo.gif", False, True, .Range(.Range.End - 1, .Range.End)
'内嵌图像(相当于绘图)
'.Shapes.AddLine 200, 500, 200, 550 'y为竖向,x为水平方向
'.Shapes.AddPicture App.Path & "/blog_logo.gif", , , 100, 550
.Content.InsertAfter vbCrLf
Set P = .Paragraphs.Add
I = .Paragraphs.Count
P.Alignment = wpsAlignParagraphRight
P.Range.Font.Name = "黑体"
P.Range.Font.Size = 15
P.LineSpacing = 10 '行距
P.Range.Text = "插入超链接:田草博客" & vbLf
.Hyperlinks.Add .Range(.Range.End - 1, .Range.End), "http://www.tiancao.net", "", "插入超链接:田草博客", "插入超链接:田草博客", "_blank"
'Set P = .Paragraphs.Add
'I = .Paragraphs.Count
WPS_Doc.Content.InsertAfter ("\n\r")
'P.Range.Text = "第一页"
'P.Alignment = wpsAlignParagraphCenter
'P.Range.Font.Name = "仿宋_GB2312"
'.Content.Font.Size = 16
'.Sections.Add
'文档另存为
'.SaveAs FileName:=App.Path & "/Sample.wps"
'文档打印(将直接使用默认打印机全部打印)
'.PrintOut
'关闭
'.Close
End With
End Sub
Dim WPS_Doc As WPS.Document
Dim P As WPS.Paragraph
Dim I As Integer
Private Sub Command1_Click()
'启动WPS应用程序
Set WPS_App = CreateObject("wps.application")
'程序可见最大化
WPS_App.Visible = True
WPS_App.WindowState = wpsWindowStateMaximize
'新建文档
Set WPS_Doc = WPS_App.Documents.Add()
'设置页边距
With WPS_Doc.PageSetup
.PageHeight = CentimetersToPoints(59.4)
.PageWidth = CentimetersToPoints(21#)
.TopMargin = CentimetersToPoints(2.5)
.BottomMargin = CentimetersToPoints(2#)
.LeftMargin = CentimetersToPoints(2#)
.RightMargin = CentimetersToPoints(1.5)
End With
With WPS_Doc
Set P = .Paragraphs.Add
I = .Paragraphs.Count
P.Range.Font.Name = "黑体"
P.Range.Font.Size = 15
P.Alignment = wpsAlignParagraphCenter
P.Range.Text = "黑体 15 居中对齐" & vbLf
Set P = .Paragraphs.Add
I = .Paragraphs.Count
P.Range.Font.Name = "宋体"
P.Range.Font.Size = 15
P.Alignment = wpsAlignParagraphCenter
P.Range.Text = "插入3行5列表格"
'插入3行5列表格
Set P = .Paragraphs.Add
I = .Paragraphs.Count
P.Alignment = wpsAlignParagraphLeft
.Tables.Add .Range(.Range.End - 1, .Range.End), 3, 5, , wpsAutoFitFixed
With .Tables(1)
.Cell(2, 3).Range.Font.Name = "楷体"
.Cell(2, 3).Range.Font.Size = 10
.Cell(2, 3).Range.Text = "第二行,第三列"
.Cell(2, 3).Borders(wpsBorderRight).Color = wpsColorLightYellow
.Columns.Width = 100
.Rows.Height = 20
End With
Set P = .Paragraphs.Add
I = .Paragraphs.Count
P.Range.Font.Name = "隶书"
P.Range.Font.Size = 15
P.Range.Font.Color = wpsColorRed
P.Alignment = wpsAlignParagraphLeft
P.LineSpacing = 50 '行距
P.Range.Text = "段落3 隶书 字体大小15 居左,行距50,颜色红色" & vbLf
Set P = .Paragraphs.Add
I = .Paragraphs.Count
P.Range.Font.Name = "黑体"
P.Range.Font.Size = 15
P.Alignment = wpsAlignParagraphCenter
P.LineSpacing = 10 '行距
P.Range.Text = "段落4 插入图片" & vbLf
'嵌入图像
P.Range.InlineShapes.AddPicture App.Path & "/blog_logo.gif", False, True, .Range(.Range.End - 1, .Range.End)
'内嵌图像(相当于绘图)
'.Shapes.AddLine 200, 500, 200, 550 'y为竖向,x为水平方向
'.Shapes.AddPicture App.Path & "/blog_logo.gif", , , 100, 550
.Content.InsertAfter vbCrLf
Set P = .Paragraphs.Add
I = .Paragraphs.Count
P.Alignment = wpsAlignParagraphRight
P.Range.Font.Name = "黑体"
P.Range.Font.Size = 15
P.LineSpacing = 10 '行距
P.Range.Text = "插入超链接:田草博客" & vbLf
.Hyperlinks.Add .Range(.Range.End - 1, .Range.End), "http://www.tiancao.net", "", "插入超链接:田草博客", "插入超链接:田草博客", "_blank"
'Set P = .Paragraphs.Add
'I = .Paragraphs.Count
WPS_Doc.Content.InsertAfter ("\n\r")
'P.Range.Text = "第一页"
'P.Alignment = wpsAlignParagraphCenter
'P.Range.Font.Name = "仿宋_GB2312"
'.Content.Font.Size = 16
'.Sections.Add
'文档另存为
'.SaveAs FileName:=App.Path & "/Sample.wps"
'文档打印(将直接使用默认打印机全部打印)
'.PrintOut
'关闭
'.Close
End With
End Sub
[本日志由 tiancao1001 于 2009-02-07 10:15 AM 编辑]
|
暂时没有评论
发表评论 - 不要忘了输入验证码哦! |