20170907wdVBA_ImportPicturesBaseOnExcel
Public Sub ImportPicturesBaseOnExcel()
Dim shp As Object
Dim xlApp As Object
Dim Wb As Object
Dim Rng As Object
Dim FolderPath As String
Dim ImgFolder As String
Dim ExcelPath As String
Dim FilePath As String
Const ExcelFile As String = "身份证号.xls"
FolderPath = ThisDocument.Path & "\"
ExcelPath = FolderPath & ExcelFile
ImgFolder = FolderPath & "照片\"
On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
If xlApp Is Nothing Then
Set xlApp = CreateObject("Excel.Application")
End If
On Error GoTo 0
Set Wb = xlApp.workbooks.Open(ExcelPath)
EndRow = Wb.worksheets(1).Range("A65536").End(3).Row
Set Rng = Wb.worksheets(1).Range("A2:A" & EndRow)
arr = Rng.Value
Wb.Close
xlApp.Quit
If ThisDocument.InlineShapes.Count > 0 Then
For Each shp In ThisDocument.InlineShapes
shp.Delete
Next shp
End If
If ThisDocument.Shapes.Count > 0 Then
For Each shp In ThisDocument.Shapes
shp.Delete
Next shp
End If
Selection.WholeStory
Selection.Delete
Selection.HomeKey wdStory
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
For i = LBound(arr) To UBound(arr)
FilePath = ImgFolder & "*" & arr(i, 1) & "*.jpg"
Debug.Print FilePath
FileName = Dir(FilePath)
If FileName <> "" Then
FilePath = ImgFolder & FileName
n = n + 1
For j = 1 To 2
Set shp = ThisDocument.InlineShapes.AddPicture(FileName:=FilePath, _
LinkToFile:=False, SaveWithDocument:=True)
Selection.Collapse wdCollapseEnd
Next j
If n Mod 2 = 0 And n Mod 8 <> 0 Then
Selection.EndKey wdStory
Selection.TypeParagraph
End If
If n Mod 8 = 0 Then
Selection.EndKey wdStory
Selection.InsertBreak Type:=wdPageBreak
End If
End If
Next i
Set shp = Nothing
End Sub
20170907wdVBA_ImportPicturesBaseOnExcel的更多相关文章
随机推荐
- rsync命令解析
!rsync同步模式sync在进行同步或备份时,使用远程shell,或TCP连接远程daemon,有两种途经连接远程主机.shell模式,不需要使用配置文件,也不需要启动远端rsync.远程传输时一般 ...
- ODAC(V9.5.15) 学习笔记(三)TOraSession(2)
2. 事务相关 名称 类型 说明 AutoCommit Boolean 是否自动提交事务 注意:只有当TOraSession和TOraQuery的AutoCommit都为True时才对每个数据库操作自 ...
- Read.csv: some rows are missing
read.csv in R doesn't import all rows from csv file The OP indicates that the problem is caused by q ...
- An Empirical Evaluation of Generic Convolutional and Recurrent Networks for Sequence Modeling
An Empirical Evaluation of Generic Convolutional and Recurrent Networks for Sequence Modeling 2018-0 ...
- RabbitMQ学习之延时队列
原帖参考:http://www.cnblogs.com/telwanggs/p/7124687.html?utm_source=itdadao&utm_medium=referral http ...
- Mysql数据类型、约束、存储引擎
一.数据类型 整数类型 默认有符号的 设置为无符号 1.create table t2(age tinyint unsigned); 2.建表后用alter修改 tinyint[(m)] [unsig ...
- 2、Keepalived提供日志与双主模型演示
Keepalived实例演示: 利用keepalived流动一个VIP,在提供LVS的高可用以及实现对LVS后端的real server做健康状态检测,最后实现高可用nginx. HA Clust ...
- 增强 用文本增强修改SAP标准屏幕中的字段名称 属于元素的文本增强
如果想要改变标准屏幕中的字段名称,如把物料主数据基本数据元素的名字改为我们想要的名字 . 1.首先,事务MM03进入物料主数据的基本数据2视图中,将鼠标光标放在需要更改的字段“页格式”上,然后按F1键 ...
- CART决策树
CART(Classification and Regression tree)分类回归树由L.Breiman,J.Friedman,R.Olshen和C.Stone于1984年提出.ID3中根据属 ...
- Django中ORM简介与单表数据操作
一. ORM简介 概念:.ORM框架是用于实现面向对象编程语言种不同类型系统的数据之间的转换 构建模型的步骤:重点 (1).配置目标数据库信息,在seting.py中设置数据库信息 DATABASE ...