Okay ive been looking everywhere and I can't find this. Ive used the help documents and tried to use the Shell function and also Process.Start. So say I have a file at relative path /Data/manual.pdf (i know how to get directory of application to create absolute path). But I need to open this file with an .exe located at /Data/reader.exe

How would I do this?
Cheers,
Jordan

Your question is a little vague. If you want to open another program as in your pdf above WITHIN your application, you need to put a reference to that program. Else your shell should open that program independantly, so the actual question is, what exactly do you need? Open another .exe on its own or open it using your application referencing that programs dll's etc?

If it is on its own, use shell as follow. You will see that I made use of a standard sub to call the shell, else it will only open certain .exe's.

Private Sub RunShellExecute(sTopic As String, sFile As Variant, sParams As Variant, sDirectory As Variant, nShowCmd As Long)

Dim hWndDesk As Long
Dim success As Long
  
  'the desktop will be the
  'default for error messages
hWndDesk = GetDesktopWindow()
  
  'execute the passed operation
success = ShellExecute(hWndDesk, sTopic, sFile, sParams, sDirectory, nShowCmd)

  'This is optional. Uncomment the three lines
  'below to have the "Open With.." dialog appear
  'when the ShellExecute API call fails
  'If success < 32 Then
  '   Call Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " & sFile, vbNormalFocus)
  'End If
End Sub

'Under a control like i.e. command button -

Private Sub Command1_Click(ByVal Button As Integer)

Dim x As Double
x = Shell("rundll32.exe shell32.dll,Control_RunDLL", vbMaximizedFocus)
End Sub

Is this what you were looking for?

Andre! Really! .BLOAT code in the vb6.0 forum? Shame on you! :)

Jaws,

Using the shell function, shellexecute(ex) API with the open verbs will only open the destined file with the default program. If you want to open a file with another program than the one registered as the default, you will need to hope it accepts command line parameters and you could pass the path of the file to the exe that is to open it... (c:\Program Files\MyProgram.ext o/c:\ProgramData\MyProgramName\filename). Another way would be to automate the other program and make it open the file...

Good Luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.