Shell programming

  • Thread starter Thread starter Roger
  • Start date Start date
R

Roger

Can anyone help ,pleas?

I am developing an Asset Register in MS Access - using the template already
in Access as my developmental platform.

I tried using the wizard to write the VBA code which runs an external
application.
The wizard appears to write the code properly - however when Itry and run
the code I get this error message - "Invalid procedure call or argument".

Can anyone explain why?

Regards

Roger D
 
Douglas,

The code generated is as follows :

Private Sub Command7_Click()
On Error GoTo Err_Command7_Click

Dim stAppName As String

stAppName = "C:\Documents and Settings\admin\Desktop\RAD.txt"
Call Shell(stAppName, 1)

Exit_Command7_Click:
Exit Sub

Err_Command7_Click:
MsgBox Err.Description
Resume Exit_Command7_Click

End Sub
 
Shell isn't appropriate for non-executable files. Try

Private Sub Command7_Click()
On Error GoTo Err_Command7_Click

Dim stAppName As String

stAppName = "C:\Documents and Settings\admin\Desktop\RAD.txt"
Application.FollowHyperlink stAppName

Exit_Command7_Click:
Exit Sub

Err_Command7_Click:
MsgBox Err.Description
Resume Exit_Command7_Click

End Sub
 
08 Jan 2009

Douglas ,

Thanks for the reply.

However I had to change the file type from a ".mdb" to a ".txt" file type.

Is MS Access considered an ".exe" file type?

The reason I am asking is that the problem is happening even with an Access
database.

Thanks in advance.

Regards

Roger
 
No, I don't believe an MDB is considered to be an executable: that would be
..exe, .cmd or .bat

Did you try my suggestion?
 
i didn't get around to actually trying out your solution,but looking at the
code i understand what it does and don't envisage any problems implementing
it ; however I will contact you,via the newsgroup, if I do.

Thanks again.

Rgds
Roger
 
Hi Roger,
As Douglas said the shell work with executable files i.e. .exe,.com,.bat etc.
If you wanna open a txt file you must specify the path of a program who can
handle them so that if, for example, we wanna open your file with notepad:

Call Shell("c:\windows\notepad.exe C:\Documents and
Settings\admin\Desktop\RAD.txt", 1)

HTH Paolo
 
<picky>
That won't work due to the space in the path to the text file.

You'd need

Call Shell("c:\windows\notepad.exe ""C:\Documents and
Settings\admin\Desktop\RAD.txt""", 1)
</picky>
 
An *.mdb file (or *.mde) is not an executable - the terms of being an
APPLICATION. They are just like .txt, .doc, .xls and any one of a thousand
different file extensions. If the file extension is associated with an .EXE
then selecting then opening the file will run the .EXE by default.
 
Paolo said:
As Douglas said the shell work with executable files i.e. .exe,.com,.bat etc.
If you wanna open a txt file you must specify the path of a program who can
handle them so that if, for example, we wanna open your file with notepad:

Call Shell("c:\windows\notepad.exe C:\Documents and
Settings\admin\Desktop\RAD.txt", 1)

While "C:\windows" will work in 99.9% of the time the 0.01% of the
time Windows will reside in another folder. Maybe even in another
drive.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
Yeah, I know, actually it was just an example based on my pc, but thanx for
the comment
Cheers Paolo
 
Back
Top