Using RunApp to access file(s)

  • Thread starter Thread starter Kevin
  • Start date Start date
K

Kevin

Guest
Help!
I have a similar question to Yarlie's regarding opening Word files. I have created a RunApp button that when clicked will open a Word file named wordfile1.doc (the code is below). Right now it's hardcoded to open only one file (wordfile1.doc). My problem: I want the RunApp to dynamically open a Word file based on the value in a field (named "filename") of the current record. For example, if "filename" in record # 2 contains the value "wordfile2", Word would automatically open e:\Kevin\wordfile2.doc.

Needing help,

Don

Private Sub wORD_BUTTON_Click()
On Error GoTo Err_wORD_BUTTON_Click
Dim stAppName As String
stAppName = "C:\Program Files\Microsoft Office\Office\WINWORD.EXE e:\Kevin\wordfile1.doc"
Call Shell(stAppName, 1)
Exit_wORD_BUTTON_Click:
Exit Sub
Err_wORD_BUTTON_Click:
MsgBox Err.Description
Resume Exit_wORD_BUTTON_Click
End Sub
 
Try This

Private Sub wORD_BUTTON_Click()
On Error GoTo Err_wORD_BUTTON_Click
Dim stAppName As String
stAppName = "C:\Program Files\Microsoft Office\Office\WINWORD.EXE e:\Kevin\" & Forms![YourFormName].[filename]
Call Shell(stAppName, 1)
Exit_wORD_BUTTON_Click:
Exit Sub
Err_wORD_BUTTON_Click:
MsgBox Err.Description
Resume Exit_wORD_BUTTON_Click
End Sub
 

Users who are viewing this thread

Back
Top Bottom