| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 847 人关注过本帖
标题:关于VB编程,小菜勿访
只看楼主 加入收藏
youphua
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2006-4-24
收藏
 问题点数:0 回复次数:4 
关于VB编程,小菜勿访
如何将VB界面上text控件中的文本内容另存到word中?(通过控件或代码实现)
搜索更多相关主题的帖子: VB 小菜 
2006-04-25 10:17
youphua
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2006-4-24
收藏
得分:0 

是朋友就过来指教一下,谢谢!
 给我这个新手一点希望呀!!!

2006-04-25 10:19
beyondlylyly
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-5-26
收藏
得分:0 
用WRITE语句不是就可以了吗?
2006-05-26 15:51
hunny_2651
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-5-16
收藏
得分:0 

以前的一个演示程序,希望对你有所帮助。


Dim wddoc As Word.Document
Dim wdpg As Word.PageSetup
Dim wd As New Word.Application
Dim wshp As Word.Shape
Dim px As Word.Paragraph
Dim tabx As Word.Table

Private Sub Command1_Click()
CD.ShowOpen
Text1.Text = CD.FileName
End Sub

Private Sub Command2_Click()
wd.Documents.Add
Set wddoc = wd.ActiveDocument
Set wdpg = wddoc.PageSetup
wdpg.PaperSize = wdPaperA4 '7 A3=6


wdpg.TopMargin = 150 * 8 / 28.2 '1.34
wdpg.BottomMargin = 111 * 8 / 28.2
wdpg.LeftMargin = 200 * 8 / 28.2 '1.79 25=2.24
wdpg.RightMargin = 90 * 8 / 28.2
'wdpg.PageWidth = InchesToPoints(14.87) ' 1070.65
'wdpg.PageHeight = InchesToPoints(11) ' 792
'wshp.Left
With wddoc.Sections(1).Footers(wdHeaderFooterPrimary) '1
.PageNumbers.Add wdAlignPageNumberRight '2,1-center
End With

With wddoc.Sections(1).Headers(wdHeaderFooterPrimary)
.Range.InsertBefore "分析报告"
.Range.ParagraphFormat.Alignment = wdAlignParagraphRight '2,1-center

'.Range.Footnotes.Add
'.Range.InsertBreak
End With
'wddoc.Paragraphs.Add
'wddoc.Paragraphs.Item (1).Range.
'Set wshp = wddoc.Shapes.AddPicture("c:\zwx1502.bmp", False, True, 41, 60) ', 493, 250)
'wddoc.Range(1).Font.Name = "宋体"
'wddoc.Range(1).Font.Size = 9
'wddoc.Range(1).Text = "测试文档" + Chr(13) + Chr(13) + Chr(13)
Set px = wddoc.Paragraphs.Add
wddoc.Paragraphs.Item(1).Range.Bold = True
wddoc.Paragraphs.Item(1).Range.Text = "数据分析报告"
wddoc.Paragraphs.Item(1).Alignment = wdAlignParagraphCenter

Set px = wddoc.Paragraphs.Add
wddoc.Paragraphs.Item(2).Alignment = wdAlignParagraphCenter '1
Call wddoc.Paragraphs.Item(2).Range.InlineShapes.AddPicture(App.Path & "\IBM T42.jpg", False, True)
Set px = wddoc.Paragraphs.Add
wddoc.Paragraphs.Item(3).Alignment = wdAlignParagraphLeft '0
wddoc.Paragraphs.Item(3).Range.Font.Size = 9
'wddoc.Paragraphs.Item(3).Range.Text = ""
Set px = wddoc.Paragraphs.Add
wddoc.Paragraphs.Item(4).Range.Text = "1自然段把剪贴板上的图片贴到word的指定段落。把剪贴板上的图片贴到word的指定段落。把剪贴板上的图片贴到word的指定段落。把剪贴板上的图片贴到word的指定段落。把剪贴板上的图片贴到word的指定段落。"
Set px = wddoc.Paragraphs.Add
wddoc.Paragraphs.Item(5).Range.Font.Color = wdColorRed
wddoc.Paragraphs.Item(5).Range.Text = "2自然段把剪贴板上的图片贴到word的指定段落。把剪贴板上的图片贴到word的指定段落。把剪贴板上的图片贴到word的指定段落。把剪贴板上的图片贴到word的指定段落。把剪贴板上的图片贴到word的指定段落。"
Set px = wddoc.Paragraphs.Add
wddoc.Paragraphs.Item(6).Range.Font.Color = wdColorBlack
wddoc.Paragraphs.Item(6).Range.Text = ""
Set tabx = wddoc.Paragraphs.Item(6).Range.Tables.Add(wddoc.Paragraphs.Item(6).Range, 5, 6) '5行6列
tabx.Borders.InsideColor = wdColorLightOrange
tabx.Borders.OutsideColor = wdColorSkyBlue
tabx.Rows.Alignment = wdAlignRowCenter
tabx.Rows(1).Range.Bold = True
tabx.Rows(1).Height = 20
tabx.Rows(2).Height = 12

tabx.Rows(1).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
tabx.Rows(1).Cells.VerticalAlignment = wdCellAlignVerticalCenter
tabx.Cell(1, 1).Range.Text = "年份"
tabx.Cell(1, 2).Range.Text = "月份"
tabx.Columns(1).Width = 42
tabx.Columns(2).Width = 32

tabx.Cell(5, 6).Range.ParagraphFormat.Alignment = wdAlignParagraphRight
tabx.Cell(5, 6).Range.Text = "9,931.27"
tabx.Cell(5, 1).Range.Text = "31.21"
'Call wddoc.Activate
wd.ActiveDocument.SaveAs (Text1.Text)
wd.Visible = True
End

End Sub

2006-05-26 19:54
hyhhd
Rank: 2
等 级:论坛游民
威 望:1
帖 子:502
专家分:44
注 册:2006-5-12
收藏
得分:0 
同意4楼说的做法。

2006-05-26 23:12
快速回复:关于VB编程,小菜勿访
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011493 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved