Solved

Very simple Question

Posted on 1998-07-14
2
141 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Basic Excel Formatting error 4 85
VBA filters 2 51
Getting warning: You are about to delete 1 row(s) 9 43
Problem to With line 4 43
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now