Solved: Command button to open document.
(Differences Noted in RED)
Can anyone tell me why if I use this code:
[VBA]Private Sub OpenIAG_Click()
On Error GoTo Err_OpenIAG_Click
Dim stAppName As String
stAppName = "explorer.exe " & "M:\Student_Files\My_Students\" & Forms!FrmStudentTracking.Form.Forename.Value & "_" & Forms!FrmStudentTracking.Form.Surname.Value & "\" & Forms!FrmStudentTracking.Form.Forename.Value & "_" & Forms!FrmStudentTracking.Form.Surname.Value & "_-_IAG.xls"
Call Shell(stAppName, 1)
Exit_OpenIAG_Click:
Exit Sub
Err_OpenIAG_Click:
MsgBox Err.Description
Resume Exit_OpenIAG_Click
End Sub[/VBA]to call a file (M:\Student_Files\My Students\Stephen Jones\Stephen Jones - IAG.xls) I get a dialogue box asking if I want to open, save or cancel; yet if I use this code
[VBA]Private Sub OpenIAG_Click()
On Error GoTo Err_OpenIAG_Click
Dim stAppName As String
stAppName = "excel.exe " & "M:\Student_Files\My_Students\" & Forms!FrmStudentTracking.Form.Forename.Value & "_" & Forms!FrmStudentTracking.Form.Surname.Value & "\" & Forms!FrmStudentTracking.Form.Forename.Value & "_" & Forms!FrmStudentTracking.Form.Surname.Value & "_-_IAG.xls"
Call Shell(stAppName, 1)
Exit_OpenIAG_Click:
Exit Sub
Err_OpenIAG_Click:
MsgBox Err.Description
Resume Exit_OpenIAG_Click
End Sub[/VBA]I get the message:
'M;\Student_Files\My_Students\Stephen_Jones\Stephen_Jones_-_IAG.xls' could not be found.
And if I remove the Underscores the message is similar but is broken at every space giving me 7 error messages.
Any ideas, folks?!
Cross posted here