用VBA打开一个文件和dll程序
我创建了一个宏,可以在预定程序中打开文件(例如,Acrobat for pdf、Word for docs、Excel for xls)。但是,有些程序(如Windows Photo Viewer和Zip文件程序)是dll文件。如何修改代码以使其适用于非.exe应用程序用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
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)
进一步注意:如果文件没有关联,它应该仍然运行,但会提示您指定一个打开文件的程序