当我点击指定了宏的按钮(在另一个工作表中)时,我想基于另一个工作表“路径”单元格C2中的文件路径打开一个特定的PDF。
我上个月刚开始学习vba,到目前为止我有这个,但我遇到了一个错误-
Sub Sample()
ActiveWorkbook.FollowHyperlink Sheets("Paths").Range("C2")
End Sub
错误是:
运行时错误'-214722104 (800401ea)':无法打开指定的文件。
请帮帮忙。
发布于 2021-09-09 23:50:51
我认为脚本上没有错误。请检查以下几点。
所示
请检查一下。
发布于 2021-09-11 03:15:47
我只是绕了个弯路打开了pdf。
‘子OpenCIS()
Sheets("Paths").Select
Range("C3").Select
Selection.Copy
Dim x As Variant
Dim Path As String
' Set the Path variable equal to the path of your program's installation
Path = Sheets("Paths").Range("C2")
x = Shell(Path, vbNormalFocus)
Application.Wait Now + 0.00002
Application.SendKeys "^{o}", True
Application.Wait Now + 0.00002
Application.SendKeys "^{v}", True
Application.SendKeys "{HOME}", True
Application.SendKeys "{DEL}", True 'deletes the ? that appears before the path
Application.SendKeys "{ENTER}", True
End Sub‘’我不知道路径为什么显示为?C:\Users\Renee Arianne\Desktop\Desktop - Filled CIS\CIS_2016 v5 filled.pdf。
https://stackoverflow.com/questions/69122600
复制相似问题