Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1598|回复: 3

请问这段代码要改为工作薄的所有工作表同时执行,怎么弄?

[复制链接]
发表于 2016-8-2 15:55 | 显示全部楼层 |阅读模式
本帖最后由 naturalcyh1 于 2016-8-2 16:04 编辑

谢谢各位,我的工作表改了名字的,为“风景图表”、“商务图表”、“建筑图标”………………
代码如下:


Const beishu = 3 '在这里调整放大倍数,当前为2倍
Sub 单击图片放大()
Dim target, sht, rn, mypath, shp, i
For Each shp In Sheets(1).Shapes
  shp.OnAction = "ActionClick"
Next
End Sub

Sub ActionClick()
Static n, x
    Application.ScreenUpdating = False
If x = Application.Caller Then
    n = n + 1
    If (n Mod 2) = 1 Then
    With Sheet1.Shapes(Application.Caller)
        .ScaleHeight beishu, msoFalse, msoScaleFromTopLeft
        .ScaleWidth beishu, msoFalse, msoScaleFromTopLeft
        .ZOrder msoBringToFront
    End With
    Else
    With Sheet1.Shapes(Application.Caller)
        .ScaleHeight 1 / beishu, msoFalse, msoScaleFromTopLeft
        .ScaleWidth 1 / beishu, msoFalse, msoScaleFromTopLeft
        .ZOrder msoBringToFront
    End With
    End If
Else
    If (n Mod 2) = 1 Then
      With Sheet1.Shapes(x)
        .ScaleHeight 1 / beishu, msoFalse, msoScaleFromTopLeft
        .ScaleWidth 1 / beishu, msoFalse, msoScaleFromTopLeft
        .ZOrder msoBringToFront
      End With
      With Sheet1.Shapes(Application.Caller)
        .ScaleHeight beishu, msoFalse, msoScaleFromTopLeft
        .ScaleWidth beishu, msoFalse, msoScaleFromTopLeft
        .ZOrder msoBringToFront
      End With
    Else
      With Sheet1.Shapes(Application.Caller)
        .ScaleHeight beishu, msoFalse, msoScaleFromTopLeft
        .ScaleWidth beishu, msoFalse, msoScaleFromTopLeft
        .ZOrder msoBringToFront
      End With
      n = n + 1
    End If
      x = Application.Caller

End If
    Application.ScreenUpdating = True
End Sub

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2016-8-2 18:06 | 显示全部楼层
回复

使用道具 举报

发表于 2016-8-2 22:22 | 显示全部楼层
回复

使用道具 举报

发表于 2016-8-2 23:01 | 显示全部楼层
二楼的回复是你改了标题前发的。说明下。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-4 05:08 , Processed in 0.303042 second(s), 11 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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