shell 显示未从Excel VBA嵌入的图片

8tntrjer  于 2023-05-18  发布在  Shell
关注(0)|答案(2)|浏览(125)

以下命令在命令提示符下工作:
%SystemRoot%\System32\rundll32.exe“C:\Program Files\Windows Photo Viewer\PhotoViewer.dll”,ImageView_Fullscreen C:\Test.jpg
在Excel VBA中,我尝试了几种方法。下面的第一个示例得到53文件未找到。第二个示例似乎正在运行,但没有显示任何内容。

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

我不想在Excel中嵌入照片。它们经常更新。
以下操作成功打开PhotoViewer:

VBA.Shell "C:\Windows\System32\rundll32.exe ""C:\Program Files\Windows Photo Viewer\PhotoViewer.dll"", ImageView_Fullscreen"
gstyhher

gstyhher1#

Sub test()

    Dim sFile As String
    
    sFile = "C:\Users\cyboashu\Desktop\future.jpg"
    
    '/ Open in default image editor
    CreateObject("Shell.Application").Open CVar(sFile)
    
End Sub
p3rjfoxz

p3rjfoxz2#

我终于想明白了。照片的完整路径在ActiveCell中,用引号括起来。

Sub ViewPhoto()
        VBA.Shell "C:\Windows\System32\rundll32.exe ""C:\Program Files\Windows Photo Viewer\PhotoViewer.dll"", ImageView_Fullscreen " & ActiveCell.Value
    End Sub

相关问题