Office中国论坛/Access中国论坛

标题: (以解決)查詢圖片2003可用改用2007不能用With Application.FileSearch [打印本页]

作者: joyark    时间: 2011-4-8 16:23
标题: (以解決)查詢圖片2003可用改用2007不能用With Application.FileSearch
本帖最后由 joyark 于 2011-4-20 21:25 编辑

Option Explicit
Sub fdjpg(nm As String)
With Application.FileSearch   '這裡出現問題
.LookIn = ThisWorkbook.Path
    .SearchSubFolders = True
    .Filename = nm & ".jpg"
    If .Execute <> 0 Then
        nm = .FoundFiles(1)
    Else
        nm = ""
    End If
End With
End Sub
Sub addPic(tgRng As Range)
Dim rng As Range
Dim nm As String
Dim shp As Shape
With tgRng
    nm = .Text
    Set rng = .Offset(0, -2).Resize(15, 1)
End With
    fdjpg nm
If nm <> "" Then
    rng.Worksheet.Pictures.Insert(nm).Select
    With Selection
        .Top = rng.Top
        .Left = rng.Left
        .Placement = xlMoveAndSize
        .Width = rng.Width
        .Height = rng.Height
    End With
Else
    MsgBox nm & " not found!"
End If
End Sub

作者: roych    时间: 2011-4-8 17:49
2007版本宏的安全性比较高,可能需要设置受信任位置才行。——我的本本没装2007版本,暂时无法为您调试。目前下载的附件是没问题的。
此外,建议在VBE界面里点击工具\引用,看看Office库是否引用正确(如果有Missing或者丢失字样就需要重新引用了)。
作者: joyark    时间: 2011-4-8 19:34
roych謝謝
我常调试沒有成功
作者: joyark    时间: 2011-4-19 20:32
請幫忙解決
作者: joyark    时间: 2011-4-20 21:25
解決文件地址:http://www.officefans.net/cdb/vi ... &extra=page%3D1




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3