Run Application doesn't work

  • Thread starter Thread starter Dorothy
  • Start date Start date
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
 
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
 
Back
Top