つらつら Excel VBA

私の備忘録です。

関連付けられたアプリケーションでファイルを開く

Dim WSH As Object

Set WSH = CreateObject("WScript.Shell")
WSH.Run Chr(34) & FilePath & Chr(34)

'Set WSH = Nothing

※Chr(34)でFilePathを囲む必要がある。Chr34はダブルクォーテーション。
囲まないとファイルパスに空白が含まれていた場合に失敗する。

以上。