Solved

Very simple Question

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

747 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

11 Experts available now in Live!

Get 1:1 Help Now