Ok, I didn't receive any SIMPLE ways to do this, but I did come up with a solution which is working like a charm for Excel and Word 2007 files (.xlsx and .docx) (thanks to multiple threads and guidelines from others). I figured that I would post it here just in case anyone else can benefit from it. SO ...
FIRST AND FOREMOST --- You must select the Microsoft Excel 12.0 Object Library and the Microsoft Word 12.0 Object Library from the Tools --> References in the Visual Basic editor. Without these selected, the below code WILL NOT WORK!!!
In my button OnClick event, I included the following code:
Code:
On Error GoTo ErrorHandler
Dim FileNm As String
Dim PPCAttachDir As String
Dim PPCOpenFile As String
Dim xlApp As Excel.Application
FileNm = Me.FileName
PPCAttachDir = "[Enter your static folder structure here or use a Variable (I use a global variable)] " & FileNm
PPCOpenFile = PPCAttachDir & "\" & PPCAttachFile
Debug.Print PPCOpenFile
If Len(Dir(PPCOpenFile, vbNormal)) = 0 Then
MsgBox "The file " & PPCAttachFile & " has been moved, renamed, or deleted. Please click on " & _
"the folder link on the Request Form to verify the file name and update it as needed." _
, vbOKOnly + vbExclamation, "File Not Found"
GoTo ExitHere
ElseIf PPCAttachFile Like "*.xlsx*" Then
Call OpenXLSXFile(PPCOpenFile) 'Located in basAttachments
GoTo ExitHere
ElseIf PPCAttachFile Like "*.docx*" Then
Call OpenDOCXFile(PPCOpenFile) 'Located in basAttachments
GoTo ExitHere
ElseIf PPCAttachFile Like "*.msg" Then
'I still haven't figured out how to open .msg files yet, so I have this work around for my users
MsgBox "Outlook Message files cannot be opened from within the database. You must " & _
"open the email file directly from the attachment folder." & vbCrLf & vbCrLf & "The " & _
"attachment folder will be opened for you upon closing this message box.", _
vbOKOnly + vbInformation, "Cannot Open .MSG files"
Application.FollowHyperlink PPCAttachDir
Else
Application.FollowHyperlink PPCOpenFile
End If
ExitHere:
Exit Sub
ErrorHandler:
Call UnexpectedError(Err.Number, Err.Description, Err.Source) 'Located in basMsgBoxes
Resume ExitHere
End Sub
So, the two specific calls in the code above are probably what you are wondering what I did. Ok, here is the code that is run when the OpenXLSXFile(PPCOpenFile) is called:
Code:
Sub OpenXLSXFile(OpenFile As String)
Dim xlApp As Excel.Application
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.Workbooks.Open OpenFile, True, False
Set xlApp = Nothing
End Sub
And here is the code for when the OpenDOCXFile(PPCOpenFile) is called:
Code:
Sub OpenDOCXFile(OpenFile As String)
Dim wdApp As Word.Application
Set wdApp = CreateObject("Word.Application")
wdApp.Visible = True
wdApp.Documents.Open OpenFile, True, False
Set wdApp = Nothing
End Sub
I hope that this will help anyone else looking for a solution. Unfortunately I wasn't able to pull together a simple/all in one solution, but this one is pretty simple in that if I find any other files that I can't open, I should be able to add another If Statement to my main code and then add a new Module Procedure to be called to open the file.