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

Deadly 提交于 2019-12-10 11:52:02

问题


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)?

For now, I have this VB function.

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


回答1:


Yes, you can use the Shell object to run the file.

' 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



回答2:


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

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



回答3:


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 [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)



回答4:


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



来源:https://stackoverflow.com/questions/43739496/is-there-a-way-to-a-open-a-pdf-with-a-vb-function-that-bypass-the-path-of-the-ex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!