Excel VBA用户定义的function在文件夹中查找图像
我在Excel表中的图像名称为:
16094_1.jpg 16095_1.jpg,16095_2.jpg
在逗号分隔的单元格中名称可以是单个或多个。 他们存储在位置
"C:\Users\Jatin\Desktop\Jatin\november\17-nov\images"
我想创build用户定义的函数(公式),可以find图像在所需的位置,无论它们是否存在。 例如,
=findimage("path",imagename) =findimage("C:\Users\Jatin",a1)
Function hasImages(Path As String, ImageList As String) Dim results Dim x As Long results = Split(ImageList, ",") If Not Right(Path, 1) = "\" Then Path = Path & "\" For x = 0 To UBound(results) results(x) = Len(Dir(Path & results(x))) > 0 Next hasImages = Join(results, ",") End Function
你可以试试这个function:
Function IfFileExist(strPath As String, strFileName As String) IfFileExist = False If Len(Dir(strPath & "\" & strFileName)) > 0 Then IfFileExist = True End If End Function
- 匹配2个单元格中的数据并用第三个单元格中的数据replace(Excel)
- 如何将string格式化为date – Microsoft Project导出到Excel?
- 仅在已过滤的PivotItems上执行循环
- 旧格式或无效的types库。 (从HRESULTexception:0x80028018(TYPE_E_INVDATAREAD))
- 在没有剪贴板的工作簿之间复制/粘贴variables数据集
- 如何通过Excel中的Worksheet_Selection更改logging多个工作表中的多个更改
- Excel:如何将用户定义的函数应用于许多元素,然后求和它们?
- 目标和复制从一个Excel文件select到另一个 – C#
- 条件格式化VBA多个条件