Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用VBA打开一个文件和dll程序_Vba_Shell_Dll - Fatal编程技术网

用VBA打开一个文件和dll程序

用VBA打开一个文件和dll程序,vba,shell,dll,Vba,Shell,Dll,我创建了一个宏,可以在预定程序中打开文件(例如,Acrobat for pdf、Word for docs、Excel for xls)。但是,有些程序(如Windows Photo Viewer和Zip文件程序)是dll文件。如何修改代码以使其适用于非.exe应用程序 Sub PhotoChart() Dim strPath As String Dim strProgram As String strPath = "C:\Libraries\Photos\WeeklyPlanner

我创建了一个宏,可以在预定程序中打开文件(例如,Acrobat for pdf、Word for docs、Excel for xls)。但是,有些程序(如Windows Photo Viewer和Zip文件程序)是dll文件。如何修改代码以使其适用于非.exe应用程序

Sub PhotoChart()

Dim strPath As String
Dim strProgram As String

    strPath = "C:\Libraries\Photos\WeeklyPlanner.png"
    strProgram = "C:\Program Files (x86)\Windows PhotoViewer\PhotoViewer.dll"

    Call Shell("""" & strProgram & """ """ & strPath & """", vbNormalFocus)


End Sub

调用Shell功能不起作用。计算机发回运行时错误“5”:过程调用或参数无效

尝试改用CMD.exe中的
START
命令-如果文件类型已在系统注册表中关联,则不需要指定程序

Shell "CMD /C START " & strPath
(无需使用
呼叫
关键字btw)

进一步注意:如果文件没有关联,它应该仍然运行,但会提示您指定一个打开文件的程序