0

我正在尝试使用该Shell函数从 Excel-VBA 打开图像。第一行代码有效,但我不希望它在 Paint 中打开。正如第二行代码所建议的那样,我希望它在 Windows Live 照片库中打开,但这一行不起作用。谁能告诉我问题是什么?

Shell("mspaint.exe C:\test\Data_Sample\Figures\" & ActiveCell.Value & ".jpeg")
Shell ("WLXPhotoGallery.exe C:\test\Data_Sample\Figures\" & ActiveCell.Value & ".jpeg")

编辑 正如 BK201 建议的那样,我尝试编写 WLXPhotoGallery 可执行文件的完整路径;虽然这确实打开了 Windows Live 照片库,但它并没有打开我需要的图像。为什么?

PGallery = "C:\Program Files (x86)\Windows Live\Photo Gallery\WLXPhotoGallery.exe"
Pic = "C:\test\Data_Sample\Figures\" & ActiveCell.Value & ".jpg"
Shell (PGallery & " " & Pic)
4

2 回答 2

0

问题可能是您缺少"引号。将路径括在"引号中,否则 Windows 可能无法正确解释包含空格的路径。由于它们在字符串中,因此您实际上必须像这样写引号""。结果:

PGallery = """C:\Program Files (x86)\Windows Live\Photo Gallery\WLXPhotoGallery.exe"""
Pic = """C:\test\Data_Sample\Figures\" & ActiveCell.Value & ".jpg"""
Shell (PGallery & " " & Pic)
于 2013-11-15T07:49:37.697 回答
0

尝试使用 Windows Live 照片库的完整路径。这是因为mspaint.exe可以在 中找到system32,这就是为什么可以在不写出路径的情况下调用它的原因。WLXPG 并非如此。

Sub OpenPic()

PGallery = "C:\Program Files\Windows Live\Photo Gallery\WLXPhotoGallery\WLXPhotoGallery.exe"
Pic = 'insert path here of picture/photo
Shell (PGallery & " " & Pic)

End Sub

这是未经测试的,因此根据需要进行修改。

于 2013-11-15T01:58:18.103 回答