vb word存为html,用vb在Word文档中插入和导出图片对象

2、在Word文档中插入和导出图片对象

[vb] view plaincopy

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. On Error GoTo Errhandler

8. CommonDialog1.Filter = "Word(*.Doc)|*.Doc|AllFile(*.*)|*.*"

9. CommonDialog1.FilterIndex = 1

10. CommonDialog1.ShowOpen

11. Set WordApp = New Word.Application '实例化

12. WordApp.Documents.Open CommonDialog1.FileName '打开Word文件

13. WordApp.Visible = True '显示 Office Word 界面

14. '或者Application.Visible = True

15. WordApp.DisplayAlerts = False '不提示保存对话框

16. WordApp.Selection.EndKey Unit:=wdStory '将光标移到文档末尾,在文本后面插入图片对象

17. Selection.TypeText Text:="我的图片" '图片的标题名称

18.

19. '插入图片对象

20. Selection.InlineShapes.AddPicture FileName:="C:\CommandPicture.jpg", LinkToFile:=Fals

e, SaveWithDocument:=True

21. Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend

22. Selection.InlineShapes(1).ConvertToShape.Select

23. Selection.ShapeRange.Fill.Visible = msoFalse

24. Selection.ShapeRange.Fill.Transparency = 0#

25. Selection.ShapeRange.Line.Weight = 0.75

26. Selection.ShapeRange.Line.DashStyle = msoLineSolid

27. Selection.ShapeRange.Line.Style = msoLineSingle

28. Selection.ShapeRange.Line.Transparency = 0#

29. Selection.ShapeRange.Line.Visible = msoFalse

30. Selection.ShapeRange.LockAspectRatio = msoTrue

31. Selection.ShapeRange.Height = 361.4

32. Selection.ShapeRange.Width = 481.6

33. Selection.ShapeRange.PictureFormat.Brightness = 0.5

34. Selection.ShapeRange.PictureFormat.Contrast = 0.5

35. Selection.ShapeRange.PictureFormat.ColorType = msoPictureAutomatic

36. Selection.ShapeRange.PictureFormat.CropLeft = 0#

37. Selection.ShapeRange.PictureFormat.CropRight = 0#

38. Selection.ShapeRange.PictureFormat.CropTop = 0#

39. Selection.ShapeRange.PictureFormat.CropBottom = 0#

40. Selection.ShapeRange.RelativeHorizontalPosition = wdRelativeHorizontalPositionColumn

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值