The following code will work when run from inside Outlook 07; it prompts for a .eml file and then opens it using a shell command in the form of the "Run" prompt in the question. Unfortunately because of Microsoft's 'unique' support for VBA objects, it's not possible to call FileDialog(msoFileDialogFilePicker)
from inside Outlook.
As a result, the below calls an instance of Excel to handle the dialog box. The Application.Visible = True
line ensures the dialog box is brought to the front, as it can open behind the current application depending on the window environment.
You may need to edit C:\Program Files (x86)\Microsoft Office\Office12\Outlook.exe
to reflect the installation location of your copy of Outlook.
Sub OpenEML()
' Macro to open EML type outlook files
Dim otherObject
Dim fDialog As Office.FileDialog
Set otherObject = CreateObject("Excel.Application")
Set fDialog = otherObject.Application.FileDialog(msoFileDialogFilePicker)
With fDialog
.AllowMultiSelect = False
.ButtonName = "Open"
.Title = "Select an EML file"
'Allow only eml selection
.Filters.Add "EML", "*.eml", 1
otherObject.Application.Visible = True
.Show
otherObject.Application.Visible = False
'If some items are selected...
If .SelectedItems.Count <> 0 Then
fileNm = .SelectedItems(1)
Else
MsgBox "Nothing selected"
Exit Sub
End If
End With
Dim appNm As String
appNm = "C:\Program Files (x86)\Microsoft Office\Office12\Outlook.exe"
Dim retval
'MsgBox """" & appNm & """"
retval = Shell("""" & appNm & """" & " /eml " & """" & fileNm & """", vbNormalFocus)
End Sub