用vb在Word文档中插入和导出图片对象Word格式文档下载.doc
- 文档编号:13314711
- 上传时间:2022-10-09
- 格式:DOC
- 页数:3
- 大小:23.50KB
用vb在Word文档中插入和导出图片对象Word格式文档下载.doc
《用vb在Word文档中插入和导出图片对象Word格式文档下载.doc》由会员分享,可在线阅读,更多相关《用vb在Word文档中插入和导出图片对象Word格式文档下载.doc(3页珍藏版)》请在冰豆网上搜索。
On
Error
GoTo
Errhandler
8.
CommonDialog1.Filter
=
"
Word(*.Doc)|*.Doc|AllFile(*.*)|*.*"
9.
CommonDialog1.FilterIndex
1
10.
CommonDialog1.ShowOpen
11.
Set
New
实例化
12.
WordApp.Documents.Open
CommonDialog1.FileName
打开Word文件
13.
WordApp.Visible
True
显示
Office
界面
14.
或者Application.Visible
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:
=False,
SaveWithDocument:
=True
21.
Selection.MoveLeft
=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
29.
Selection.ShapeRange.Line.Visible
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
35.
Selection.ShapeRange.PictureFormat.ColorType
msoPictureAutomatic
36.
Selection.ShapeRange.PictureFormat.CropLeft
37.
Selection.ShapeRange.PictureFormat.CropRight
38.
Selection.ShapeRange.PictureFormat.CropTop
39.
Selection.ShapeRange.PictureFormat.CropBottom
40.
Selection.ShapeRange.RelativeHorizontalPosition
wdRelativeHorizontalPositionColumn
41.
Selection.ShapeRange.RelativeVerticalPosition
wdRelativeVerticalPositionPage
42.
Selection.ShapeRange.Left
wdShapeCenter
43.
Selection.ShapeRange.Top
44.
Selection.ShapeRange.LockAnchor
45.
Selection.ShapeRange.WrapFormat.AllowOverlap
46.
Selection.ShapeRange.WrapFormat.Side
wdWrapBoth
47.
Selection.ShapeRange.WrapFormat.DistanceTop
CentimetersToPoints(0)
48.
Selection.ShapeRange.WrapFormat.DistanceBottom
49.
Selection.ShapeRange.WrapFormat.DistanceLeft
CentimetersToPoints(0.32)
50.
Selection.ShapeRange.WrapFormat.DistanceRight
51.
Selection.ShapeRange.WrapFormat.Type
3
52.
Selection.ShapeRange.ZOrder
msoSendBehindText
设置图片为衬托于文字下方
53.
54.
判断文档中是否存在图片对象
55.
If
ActiveDocument.Shapes.Count
+
ActiveDocument.InlineShapes.Count
>
0
Then
56.
取得图片的2种方法
57.
58.
第1种方法:
用下面命令将文件另存为网页格式的文件,文件夹“MyWord.files”将保存Word文档中所有的图片
59.
这种方法对所有的Word版本均适用
60.
ActiveDocument.SaveAs
c:
\MyWord.htm"
wdFormatHTML
保存为网页格式
61.
62.
第2种方法:
引用ADO对象库,将所有的图片保存在数据库中,然后可以一张一张地显示出来
63.
64.
另外:
65.
如果Word文档是docx格式的,那可以按这个办法解决:
66.
.docx
格式的文件本质上是一个ZIP压缩文件,.docx
格式文件的主要内容是保存为XML格式的,但文件并非直接保存于磁盘。
67.
它是保存在一个ZIP文件中,然后取扩展名为.docx。
我们只需要用解压软件比如:
WinZIP、WinRAR或者7ZIP等软件进行解压就可以了。
68.
方法有两种,一种是将.docx后缀名修改为.zip后缀名;
另一个方法就是打开WinZIP然后,选择此文档即可。
69.
图片资源文件都被保存在word\media文件夹中。
70.
71.
Else
72.
Debug.Print
Word文档中不存在图片对象!
73.
End
74.
75.Errhandler:
76.
Exit
77.End
78.
79.Private
Form_Unload(Cancel
Integer)
80.
Resume
Next
81.
WordApp.Quit
82.
Nothing
83.End
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- vb Word 文档 插入 导出 图片 对象
![提示](https://static.bdocx.com/images/bang_tan.gif)