vba - 如何在不映射目标文件夹的情况下在服务器上打开 pdf 文件?
问题描述
我使用 Shell 命令打开物理上位于服务器上的 pdf 文件。该命令工作正常,因为我的计算机上映射了一个目标文件夹。我要做的是在没有映射文件夹的情况下打开文件。如果可能的话,我很难理清思绪?
这是我使用的一段代码:
Sub open_file()
VBA.Shell "Explorer.exe \\servername\Documents\2021\2\3\new_document.pdf", vbNormalFocus
End Sub
解决方案
Sub open_file()
Dim wsh
Set wsh = CreateObject("WScript.Shell")
'if path contains spaces it should be enclosed in quotes
'error handling required (path doesn't exist, pdf application isn't installed, etc.)
wsh.Run "\\servername\Documents\2021\2\3\new_document.pdf"
End Sub
推荐阅读
- php - 用于 SQL Server 的 insert ignore into 的替代方案
- r - ggpubr:在标签中显示显着性水平(*** 或 ns)而不是 p 值
- python - 交换 PANDAS 数据框中的元素
- python - 如何在 SQLAlchemy 中将 pool_timeout 设置为无穷大?
- python - 如何在 Windows 上安装 libffi-dev 和 libssl-dev
- admob - Admob 广告将在两周后开始展示
- java - 当 url 包含大括号字符时 Spring-boot 控制器错误
- excel - Excel VBA 2010:VBA 保存工作簿时数据验证中断,但手动保存时不会中断
- nginx - 如何在 Alpine Linux 容器中查找 nginx 日志
- python - Django - 如果没有匹配的 URL,则重定向到主页