电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

用VB操作word方法

用VB操作word方法_第1页
1/9
用VB操作word方法_第2页
2/9
用VB操作word方法_第3页
3/9
1. '先引用Microsoft Word 11.0 Object Library 2. Option Explicit 3. 4. Dim WordApp As Word.Application '创建Word 应用程序 5. 6. Private Sub Command1_Click() 7. Dim i As Long 8. On Error GoTo Errhandler 9. CommonDialog1.Filter = "Word(*.Doc)|*.Doc|AllFile(*.*)|*.*" 10. CommonDialog1.FilterIndex = 1 11. CommonDialog1.ShowOpen 12. Set WordApp = New Word.Application '实例化 13. WordApp.Documents.Open CommonDialog1.FileName '打开Word 文件 14. WordApp.Visible = True '显示 Office Word 界面 15. '或者Application.Visible = True 16. WordApp.DisplayAlerts = False '不提示保存对话框 17. 18. '返回段落文字,返回的段落文字在文本框控件中 19. Text1.Text = "" 20. For i = 1 To ActiveDocument.Paragraphs.Count 21. Text1.Text = Text1.Text & (ActiveDocument.Paragraphs(i).Range.Text & vbCrLf & vbCrLf) 22. Next 23. 24. '控制分页 25. WordApp.Selection.EndKey unit:=wdStory '将光标移到文档末尾 26. WordApp.Selection.InsertBreak wdPageBreak '在文档末尾插入一页 27. 28. '设置图片格式的页眉 29. If ActiveWindow.View.SplitSpecial <> wdPaneNone Then 30. ActiveWindow.Panes(2).Close 31. End If 32. If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow.ActivePane.View.Type = wdOutlineView Then 33. ActiveWindow.ActivePane.View.Type = wdPrintView 34. End If 35. ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader 36. Selection.InlineShapes.AddPicture FileName:= "F:\资料\My Pictures\2013 年元旦.gif", LinkToFile:=False, SaveWithDocument:=True '加载一图片文件作为页眉 37. Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft 38. ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument 39. 40. '设置文本格式的页眉 41. If ActiveWindow.View.SplitSpecial <> wdPaneNone Then 42. ActiveWindow.Panes(2).Close 43. End If 44. If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow.ActivePane.View.Type ...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

用VB操作word方法

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部