Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Very simple Question

Posted on 1998-07-14
2
Medium Priority
?
163 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month10 days, 11 hours left to enroll

885 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