0

The following command works in a command prompt:

%SystemRoot%\System32\rundll32.exe "C:\Program Files\Windows Photo Viewer\PhotoViewer.dll", ImageView_Fullscreen C:\Test.jpg

In Excel VBA, I have tried several things. The first example below gets 53 File not found. The second example appears to run but nothing is displayed.

    Sub ViewPhoto()

        Dim strExe As String
        strExe = """%SystemRoot%\System32\rundll32.exe ""%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll"", ImageView_Fullscreen c:\test.jpg"""
        MsgBox strExe
        'VBA.Shell strExe

        strExe = """C:\Windows\System32\rundll32.exe ""%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll"", ImageView_Fullscreen c:\test.jpg"""
        MsgBox strExe
        VBA.Shell strExe

    End Sub

I DO NOT want to embed the photos in Excel. They are updated frequently.

The following successfully opens PhotoViewer:

    VBA.Shell "C:\Windows\System32\rundll32.exe ""C:\Program Files\Windows Photo Viewer\PhotoViewer.dll"", ImageView_Fullscreen"
Derek Johnson
  • 927
  • 1
  • 11
  • 15

1 Answers1

0

I finally figured it out. The full path to the photo is in the ActiveCell, enclosed in quotes.

    Sub ViewPhoto()
        VBA.Shell "C:\Windows\System32\rundll32.exe ""C:\Program Files\Windows Photo Viewer\PhotoViewer.dll"", ImageView_Fullscreen " & ActiveCell.Value
    End Sub
Derek Johnson
  • 927
  • 1
  • 11
  • 15