I have created a macro that opens a file in a predetermined program (e.g. Acrobat for pdf, Word for docs, Excel for xls). However some programs such as Windows Photo Viewer and the Zip File program are a dll file. How do I amend my code to make it work for non .exe applications?
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)
try using the
START command in CMD.exe instead - you shouldn't need to specify the program if the file type is already associated in the system's registry.
Shell "CMD /C START " & strPath
(no need for the
Call keyword btw)
further note: If the file is not associated, it should still run but prompt you to specify a program to open the file with.