|
楼主 |
发表于 2020-5-15 19:35
|
显示全部楼层
改了一下午,总算是完成了,方法有些笨,功能实现了,麻烦过路大师帮忙看哈。
Sub 宏1()
'
' 宏1 宏
Worksheets(1).Select
lj = Sheet1.Cells(2, 4) '相片路径
xqm = Sheet1.Cells(1, 4) '小区名称
hs = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
Worksheets(2).Select
Set myDocument = Worksheets(2)
Rows("1:7").RowHeight = 105
For l = 1 To 100 Step 2
Columns(l).ColumnWidth = 16.25
Columns(l + 1).ColumnWidth = 29.13
For h = 1 To 7
i = i + 1 '第一列的行数
If i > hs Then GoTo 100:
wj = Sheet1.Cells(i, 2) '获取图片名称,图片文件名称放在1表2列。
hk = 105 * (h - 1)‘依据相片大小,偏移 行宽,’
lk = 279.6 * Int(l / 2)‘依据相片大小,偏移 列宽,’
myDocument.Shapes.AddPicture lj & wj & ".PNG", True, True, lk, hk, 104, 104
Cells(h, l + 1).Value = Sheet1.Cells(i, 1).Value
Next h
Next l
100:
bb = lj & Format(Now(), "mmddhhmmss") & xqm & ".xls"
Sheets("Sheet2").Select
Sheets("Sheet2").Copy
ActiveWorkbook.SaveAs Filename:= _
bb, FileFormat:=xlExcel8, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
ThisWorkbook.Close False '模块里关闭工作簿,且不保存。
End Sub
|
|