vba 有没有办法用绕过执行文件(Acrobat.exe)的路径的VB函数打开pdf

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43739496/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 12:32:57  来源:igfitidea点击:

Is there a way to a open a pdf with a VB function that bypass the path of the executing file (Acrobat.exe)

vbafunctionshellms-accessadobe

提问by Doum

I have a MS-Access database that is used by multiple users using different computer settings (Some people use Windows XP, others Windows 7 with Adobe Reader version 11.0 or 12.0, etc.). Is there a way to a open (from a command button in a form) a pdf file (using Adobe Reader) with a VB function that bypass a segment of the path of the executing file (Acrobat.exe)?

我有一个 MS-Access 数据库,供多个用户使用不同的计算机设置(有些人使用 Windows XP,其他人使用带有 Adob​​e Reader 版本 11.0 或 12.0 等的 Windows 7)。有没有办法使用 VB 函数打开(从表单中的命令按钮)一个 pdf 文件(使用 Adob​​e Reader),绕过执行文件(Acrobat.exe)的一段路径?

For now, I have this VB function.

现在,我有这个 VB 函数。

Call Shell("""C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\Acrobat.exe"" ""C:\DOCUMENTS\DOCUM\SPECS\Faune_DEV\SP" & Me![Element_id] & ".pdf", 1)

I want something like :

我想要类似的东西:

Call Shell("""C:\GoAndGetTheAcrobat.exeFile"" ""C:\DOCUMENTS\DOCUM\SPECS\Faune_DEV\SP" & Me![Element_id] & ".pdf", 1)

Thanks in advance

提前致谢

回答by destination-data

Yes, you can use the Shell objectto run the file.

是的,您可以使用Shell 对象运行文件

' Use Windows shell to run file.
Sub WinRun()
    Dim shell As Object
    Set shell = CreateObject("WScript.Shell")

    shell.Run "Your-Drive:\Your-Path\Your-File.pdf"
End Sub

回答by Albert D. Kallal

You can launch any windows file as if you double clicked on it with:

您可以启动任何 Windows 文件,就像双击它一样:

application.FollowHyperlink "full path name to any windows file"

回答by F.Igor

Instead of using an application program path you can use the command start.exe and it starts the default application for your file:

您可以使用命令 start.exe 而不是使用应用程序路径,它会为您的文件启动默认应用程序:

start.exe [path_to_your_pdf_file]

So you can try:

所以你可以试试:

Call Shell("""start.exe"" ""C:\DOCUMENTS\DOCUM\SPECS\Faune_DEV\SP" & Me![Element_id] & ".pdf", 1)

回答by Sadik

Call Shell("""C:\GoAndGetTheAcrobat.exeFile"" ""C:\DOCUMENTS\DOCUM\SPECS\Faune_DEV\SP" & Me![Element_id] & ".pdf", 1)

调用 Shell("""C:\GoAndGetTheAcrobat.exeFile"" ""C:\DOCUMENTS\DOCUM\SPECS\Faune_DEV\SP" & Me![Element_id] & ".pdf", 1)