p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   VB Databases Basics (http://p2p.wrox.com/forumdisplay.php?f=82)
-   -   Shell command execution error (http://p2p.wrox.com/showthread.php?t=36604)

toshesh December 30th, 2005 07:57 AM

Shell command execution error
 
Hi,

I'm getting an error when I try to run a shell command to open a file. The error is
"Run-time error '5':
Invalid procedure call or argument"

I am using ACCESS 2003 with VB 6.3 (Perhaps I am using VBA)
Here is the code below. Please someone help!!!

Code:

Private Sub OpenProposal_Click()
    Dim RetVal As Double
    RetVal = Shell("C:\db1\Proposals\tes.xls", vbNormalFocus)


End Sub


herry_basoya January 6th, 2006 02:46 AM

Use Microsoft Shell Control And Automation Reffernce in your
Project
Then
Dim ts As New Shell32.Shell
to open a file
ts.Open ("c:\files\abc.xls")
Hope it will solve your problem


toshesh January 6th, 2006 09:13 AM

Thank you for you reply!

I managed to do it another way..., got the code from some website :) Is this the same thing?

Code:


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

res = ShellExecute(hwnd, vbNullString, fname, vbNullString, vbNullString, vbNormalFocus)


herry_basoya January 7th, 2006 03:17 AM

You are using API in the code you provide
but it is OK to use API.



All times are GMT -4. The time now is 04:33 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.