Run Application doesn't work

D

Dorothy

In Access, I've tried a number of times to create a
command button on a form that when clicked opens a
document in Word but I always get an error
message "Invalid Procedure Call or Argument" Below is the
code: Does anyone see anything wrong?


Private Sub cmdOpenJV_Click()
On Error GoTo Err_cmdOpenJV_Click

Dim stAppName As String

stAppName = "M:\New File Structure\Grants-
QWL\Database\JournalVoucher AC 22.doc"
Call Shell(stAppName, 1)

Exit_cmdOpenJV_Click:
Exit Sub

Err_cmdOpenJV_Click:
MsgBox Err.Description
Resume Exit_cmdOpenJV_Click

End Sub
 
D

Dirk Goldgar

Dorothy said:
In Access, I've tried a number of times to create a
command button on a form that when clicked opens a
document in Word but I always get an error
message "Invalid Procedure Call or Argument" Below is the
code: Does anyone see anything wrong?


Private Sub cmdOpenJV_Click()
On Error GoTo Err_cmdOpenJV_Click

Dim stAppName As String

stAppName = "M:\New File Structure\Grants-
QWL\Database\JournalVoucher AC 22.doc"
Call Shell(stAppName, 1)

Exit_cmdOpenJV_Click:
Exit Sub

Err_cmdOpenJV_Click:
MsgBox Err.Description
Resume Exit_cmdOpenJV_Click

End Sub

The Shell function requires the name of an executable program, not a
document. You can call the Windows ShellExecute API using code found at
http://www.mvps.org/access/api/api0018.htm , or you can probably just
write

Application.FollowHyperlink stAppName
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top