Sheel Command

D

Dwight

I am having problem getting the shell command to work. I am trying to get it
open a file in it respective application.

I am running MS Access 2003.

My code looks like this

Dim RetVal
RetVal = Shell(strOpenDocument, 1)

' strOpenDocument is a public variable which provides the full path and
file name.
' example = "C:\My Documents\Test.doc"
 
O

Ofer

To open a word file or any other file, try and use FollowHyperlink instead of
the shell command

dim strDocToOpen as string

strDocToOpen = "C:\My Documents\Test.doc"
application.FollowHyperlink strExcelToOpen

When you run the shell, you need specify which application you want to run,
to open the document, the FollowHyperlink will run the default of windows.
 
D

Dwight

That worked great.

Thank you!

Is there a way to surpress the Microsoft message about possible viruses that
comes up.

Dwight
 
O

Ofer

I'm hapy it works.

No sorry, mybe you can start a new post asking the new question.
Or ask the Anti Virus company you are using.
 
M

mutlu

if you want to use still shell command try this one;
Make a command button and in the visual basic editor:

Private Sub cmd_Click()

Private Sub Help_button_Click()

On Error GoTo Err_Help_button_Click
Shell "winword.exe " + Chr(34) + Application.CurrentProject.Path
+ "\Nameof thewordfile.doc"
Exit_Help_button_Click:
Exit Sub

Err_Help_button_Click:
MsgBox Err.Description
Resume Exit_Help_button_Click
End Sub
(put .doc file and .mdb file in the same folder)
 
Top