Solved

Very simple Question

Posted on 1998-07-14
2
143 Views
Last Modified: 2010-05-03
I am using shell to find execute a file:
shell(App.path & "\path.txt")
This says can't find file. Is the syntax correct?
I know this file exists.
P.S. I only have five points available.
0
Comment
Question by:Coates
2 Comments
 
LVL 5

Accepted Solution

by:
dirtdart earned 0 total points
ID: 1465676
Shell won't start anything but an executable.  To start a file with its associated program, you have to use the ShellExecute API.


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

0
 
LVL 2

Expert Comment

by:swilt
ID: 1465677
To use ShellExecute

Option Explicit

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

Private Sub Command1_Click()
     Dim sDir As String
     Dim nCmd As Long, nRet As Long
     
     sDir =App.Path
     nCmd = 1
     nRet = ShellExecute(Me.hwnd, "Open", "path.txt", "", sDir, nCmd)
End Sub
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question