ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 Excel Home精品图文教程库
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
300集Office 2010微视频教程 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
12
返回列表 发新帖
楼主: 327739120

[求助] 上下页翻页自动更新对应的照片

[复制链接]

TA的精华主题

TA的得分主题

 楼主| 发表于 2021-4-14 19:01 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
pppp1  pppp2  pppp3  pppp4    pppp5   是什么意思呢?

TA的精华主题

TA的得分主题

 楼主| 发表于 2021-4-14 19:02 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
Sub 刷新5张照片()
Dim C$, PathName$
Dim MyShape1, MyShape2 As Shape
PathName = ThisWorkbook.Path & "\照片\"
On Error Resume Next
Sheets("侧贴").Shapes("PPPP1").Delete
Sheets("侧贴").Shapes("PPPP2").Delete
Sheets("侧贴").Shapes("PPPP3").Delete
Sheets("侧贴").Shapes("PPPP4").Delete
Sheets("侧贴").Shapes("PPPP5").Delete

C = Dir(PathName & Sheets("侧贴").[A6].Value & "*")
If C <> "" Then
With Sheets("侧贴").[A6:A7]
Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height)
MyShape1.Name = "PPPP1"
End With
End If
C = Dir(PathName & Sheets("侧贴").[C6].Value & "*")
If C <> "" Then
With Sheets("侧贴").[C6:C7]
Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height)
MyShape1.Name = "PPPP2"
End With
End If
C = Dir(PathName & Sheets("侧贴").[E6].Value & "*")
If C <> "" Then
With Sheets("侧贴").[E6:E7]
Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height)
MyShape1.Name = "PPPP3"
End With
End If
C = Dir(PathName & Sheets("侧贴").[G6].Value & "*")
If C <> "" Then
With Sheets("侧贴").[G6:G7]
Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height)
MyShape1.Name = "PPPP4"
End With
End If
C = Dir(PathName & Sheets("侧贴").[I6].Value & "*")
If C <> "" Then
With Sheets("侧贴").[I6:I7]
Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height)
MyShape1.Name = "PPPP5"
End With
End If
End Sub

TA的精华主题

TA的得分主题

 楼主| 发表于 2021-4-14 19:02 | 显示全部楼层
Sub 刷新5张照片() Dim C$, PathName$ Dim MyShape1, MyShape2 As Shape PathName = ThisWorkbook.Path & "\照片\" On Error Resume Next Sheets("侧贴").Shapes("PPPP1").Delete Sheets("侧贴").Shapes("PPPP2").Delete Sheets("侧贴").Shapes("PPPP3").Delete Sheets("侧贴").Shapes("PPPP4").Delete Sheets("侧贴").Shapes("PPPP5").Delete  C = Dir(PathName & Sheets("侧贴").[A6].Value & "*") If C <> "" Then With Sheets("侧贴").[A6:A7] Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height) MyShape1.Name = "PPPP1" End With End If C = Dir(PathName & Sheets("侧贴").[C6].Value & "*") If C <> "" Then With Sheets("侧贴").[C6:C7] Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height) MyShape1.Name = "PPPP2" End With End If C = Dir(PathName & Sheets("侧贴").[E6].Value & "*") If C <> "" Then With Sheets("侧贴").[E6:E7] Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height) MyShape1.Name = "PPPP3" End With End If C = Dir(PathName & Sheets("侧贴").[G6].Value & "*") If C <> "" Then With Sheets("侧贴").[G6:G7] Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height) MyShape1.Name = "PPPP4" End With End If C = Dir(PathName & Sheets("侧贴").[I6].Value & "*") If C <> "" Then With Sheets("侧贴").[I6:I7] Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height) MyShape1.Name = "PPPP5" End With End If End Sub

TA的精华主题

TA的得分主题

 楼主| 发表于 2021-4-14 19:03 | 显示全部楼层
Sub 刷新5张照片()
Dim C$, PathName$
Dim MyShape1, MyShape2 As Shape
PathName = ThisWorkbook.Path & "\照片\"
On Error Resume Next
Sheets("侧贴").Shapes("PPPP1").Delete
Sheets("侧贴").Shapes("PPPP2").Delete
Sheets("侧贴").Shapes("PPPP3").Delete
Sheets("侧贴").Shapes("PPPP4").Delete
Sheets("侧贴").Shapes("PPPP5").Delete

C = Dir(PathName & Sheets("侧贴").[A6].Value & "*")
If C <> "" Then
With Sheets("侧贴").[A6:A7]
Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height)
MyShape1.Name = "PPPP1"
End With
End If
C = Dir(PathName & Sheets("侧贴").[C6].Value & "*")
If C <> "" Then
With Sheets("侧贴").[C6:C7]
Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height)
MyShape1.Name = "PPPP2"
End With
End If
C = Dir(PathName & Sheets("侧贴").[E6].Value & "*")
If C <> "" Then
With Sheets("侧贴").[E6:E7]
Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height)
MyShape1.Name = "PPPP3"
End With
End If
C = Dir(PathName & Sheets("侧贴").[G6].Value & "*")
If C <> "" Then
With Sheets("侧贴").[G6:G7]
Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height)
MyShape1.Name = "PPPP4"
End With
End If
C = Dir(PathName & Sheets("侧贴").[I6].Value & "*")
If C <> "" Then
With Sheets("侧贴").[I6:I7]
Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height)
MyShape1.Name = "PPPP5"
End With
End If
End Sub


PPPP1.2.3.4.5什么意思?

TA的精华主题

TA的得分主题

 楼主| 发表于 2021-4-14 19:09 | 显示全部楼层
Sub 刷新5张照片()
Dim C$, PathName$
Dim MyShape1, MyShape2 As Shape
PathName = ThisWorkbook.Path & "\照片\"
On Error Resume Next
Sheets("侧贴").Shapes("PPPP1").Delete
Sheets("侧贴").Shapes("PPPP2").Delete
Sheets("侧贴").Shapes("PPPP3").Delete
Sheets("侧贴").Shapes("PPPP4").Delete
Sheets("侧贴").Shapes("PPPP5").Delete

C = Dir(PathName & Sheets("侧贴").[A6].Value & "*")
If C <> "" Then
With Sheets("侧贴").[A6:A7]
Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height)
MyShape1.Name = "PPPP1"
End With
End If
C = Dir(PathName & Sheets("侧贴").[C6].Value & "*")
If C <> "" Then
With Sheets("侧贴").[C6:C7]
Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height)
MyShape1.Name = "PPPP2"
End With
End If
C = Dir(PathName & Sheets("侧贴").[E6].Value & "*")
If C <> "" Then
With Sheets("侧贴").[E6:E7]
Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height)
MyShape1.Name = "PPPP3"
End With
End If
C = Dir(PathName & Sheets("侧贴").[G6].Value & "*")
If C <> "" Then
With Sheets("侧贴").[G6:G7]
Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height)
MyShape1.Name = "PPPP4"
End With
End If
C = Dir(PathName & Sheets("侧贴").[I6].Value & "*")
If C <> "" Then
With Sheets("侧贴").[I6:I7]
Set MyShape1 = Sheets("侧贴").Shapes.AddPicture(PathName & C, msoFalse, msoTrue, .Left, .Top, .Width, .Height)
MyShape1.Name = "PPPP5"
End With
End If
End Sub

"PPPP5" 是什么意思?

TA的精华主题

TA的得分主题

发表于 2021-4-14 22:23 | 显示全部楼层
327739120 发表于 2021-4-14 19:09
Sub 刷新5张照片()
Dim C$, PathName$
Dim MyShape1, MyShape2 As Shape

图片对象的名字,不是图片文件的名字,这个名字可以自己起,它的作用是操作图片,比如改大小,删除等等操作,还有你一起是10个人,第一页是1-5,第二页是5-9,第3页是9-10,所以楼上大神的代码没问题

TA的精华主题

TA的得分主题

发表于 2021-4-14 22:26 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
327739120 发表于 2021-4-14 19:09
Sub 刷新5张照片()
Dim C$, PathName$
Dim MyShape1, MyShape2 As Shape

强烈建议你弄几张其它能区分的照片(美女照片不香吗),我发现你自己都弄不灵清......

TA的精华主题

TA的得分主题

 楼主| 发表于 2021-4-15 19:14 | 显示全部楼层
excelstatic 发表于 2021-4-14 22:26
强烈建议你弄几张其它能区分的照片(美女照片不香吗),我发现你自己都弄不灵清......

言之有理 下次上美人计
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-5-5 14:31 , Processed in 0.034404 second(s), 8 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表