excel - Excel VBA:检查是否存在谷歌驱动器快捷方式
问题描述
我正在尝试检查是否存在通过用户的 Google Drive 的快捷方式
path = "G:\My Drive\Templates\"
If len(Dir(path, vbDirectory)) <> 0 Then
'folder or shortcut exists
如果路径是文件夹,则此代码将起作用,但如果路径是快捷方式,则不会。
任何想法如何解决?提前致谢
解决方案
基于检索快捷方式属性:
Sub test1()
shk = "c:\temp\test.lnk"
Set WshShortcut = CreateObject("WScript.Shell").CreateShortcut(shk)
Path = WshShortcut.TargetPath
If Dir(Path, vbDirectory) <> vbNullString Then
Debug.Print "Path `" & Path & "` exists"
End If
End Sub
推荐阅读
- java - 向端点发出请求错误
- android - Firebase:Reference.set 失败:指定的第一个参数路径超过了可以写入的最大深度(32)或对象包含属性中的循环
- javascript - 在带有选项的选择下拉列表中获取位置列表的最佳方法
- robotframework - 如何使用 Robotframework 中的 AutoItLibrary 将本地 Windows 机器中的图像添加到浏览器
- ng-bootstrap - 如何将 NgbTypeahead 的结果放入 DIV 容器,而不是动态下拉列表?
- kubernetes-helm - helm install 失败,值中有 - 和 _
- mysql - 在分叉的进程中使用相同的 MySQL 连接是否很好?
- spring-boot - 在作业完成之前返回 Spring Batch 作业 ID
- python - 元组列表的快速搜索
- botframework - 识别用户何时使用 Skype Web 控件 - 在 botframework 上