Here's the [MSDN article on the Shell Function](http://msdn.microsoft.com/en-us/library/aa242087%28v=VS.60%29.aspx).  Which should do what you want. basically Shell(""path""), and yes the double quotes are on purpose. :)  If I remember correctly the App object applies to the vb project and the path property is read-only and poins to the directory that the project or .exe is sitting.  As long as you have .xps associated with a program in windows then Shell should work.

Edited 3 Years Ago by tinstaafl

You must get the full path of the file, like this

App.Path & "\" & <name.ext>

Once you have it, you can call the ShellExecute API function passing as param the string you got before.

in order to execute your task , you can use the following:-

Private Declare Function ShellExecute Lib "Shell32.dll" Alias "ShellExecuteA" _
    (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
        ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd _
            As Long) As Long
Const SW_SHOW = 5

And Finally call the function in following way :-

Private Sub Command1_Click()
    Dim Filename, MyPath As String
    Filename = "test.xps"
    MyPath = App.Path & "\" & Filename
    ShellExecute hwnd, "open", MyPath, vbNullString, App.Path, SW_SHOW
End Sub

hope this helps you

This article has been dead for over six months. Start a new discussion instead.