【发布时间】:2019-03-20 16:43:58
【问题描述】:
我正在 Excel 中创建一个宏,它应该使用 chrome 在指定页面上打开 PDF 文档。
通常,开头部分有效。我的问题是,当我将页码(例如 #page=15)添加到 url 时,shell 将“#”符号编码为“%23”,Chrome 无法正确解释(找不到文件)。
这是我的代码
'The path to the file, replaces spaces with the encoding "%20"
Path = Replace((filePath& "#Page=" & iPageNum), " ", "%20")
Dim wshShell, chromePath As String, shellPath As String
Set wshShell = CreateObject("WScript.Shell")
chromePath = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe\")
shellPath = CStr(chromePath) & " -url " & Path
If Not chromePath = "" Then
'how I first tried it:
Shell (shellPath)
'for testing purposes, led to the same result though:
Shell ("""C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"" ""C:\Users\t.weinmuellner\Desktop\Evon\PDF Opening\PDFDocument.pdf#page=17""")
End If
Chrome 是否有其他方法可以做到这一点?我还没有找到任何动态读取安装路径的东西。
【问题讨论】:
-
是否也可以使用 Adobe Acrobat Reader 代替?
标签: excel vba google-chrome pdf