Excel精英培训网

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

[已解决][讨论]图片引用

[复制链接]
发表于 2011-3-9 16:01 | 显示全部楼层 |阅读模式
图片引用.rar (776.23 KB, 下载次数: 46)
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2011-3-9 20:33 | 显示全部楼层
在代码的前面加上解除工作表的代码,在代码结束的地方再加上锁定工作表的代码.
回复

使用道具 举报

发表于 2011-3-9 20:53 | 显示全部楼层    本楼为最佳答案   
Sub ad()
    Dim pth As String
    Dim pthname As String
    Dim rng1 As Range
    Dim rng2 As Range
    On Error Resume Next
    pth = ThisWorkbook.Path & "\" & "图片库\"
    Application.ScreenUpdating = False
    ActiveSheet.Unprotect '解除工作表保护
    With Sheet1
        Set rng1 = .Cells(2, 6)
        If Len(rng1.Text) Then
            Set rng2 = .Cells(8, 6)
            .Pictures(rng2.Address(0, 0)).Delete
            pthname = Dir(pth & rng1.Text & "*")
            With ActiveSheet.Pictures.Insert(pth & pthname)
                .Name = rng2.Address(0, 0)
                .Height = rng2.Height
                .Top = rng2.Top
                .Left = rng2.Left
                .Width = rng2.Width
            End With
         End If
    End With
    ActiveSheet.Protect '保护工作表
    Application.ScreenUpdating = True
End Sub
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-31 19:21 , Processed in 0.895527 second(s), 11 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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