I have had this problem for years but my solution is not acceptable for this client. I use the following VBA function to open specific files in Excel
Public Function gfunOpenExcel(inPath As Variant) As Integer
'open the given file in Microsoft Excel
Dim lsShellCommand As String 'text holding the open command and path
Dim RetVal As Long 'dummy variable
lsShellCommand = "C:\Program Files\Microsoft Office\Office\excel.exe " & inPath
RetVal = Shell(lsShellCommand, 1)
End Function
It runs fine as long as inPath does not contain spaces, so I cannot open files in "D:\My Documents\". I have tried "D:\""My Documents""\", "D:\[My Documents]\", and "D:\'My Documents'\" with no success.
There has to be a simple solution for this. Your thoughts please.
Public Function gfunOpenExcel(inPath As Variant) As Integer
'open the given file in Microsoft Excel
Dim lsShellCommand As String 'text holding the open command and path
Dim RetVal As Long 'dummy variable
lsShellCommand = "C:\Program Files\Microsoft Office\Office\excel.exe " & inPath
RetVal = Shell(lsShellCommand, 1)
End Function
It runs fine as long as inPath does not contain spaces, so I cannot open files in "D:\My Documents\". I have tried "D:\""My Documents""\", "D:\[My Documents]\", and "D:\'My Documents'\" with no success.
There has to be a simple solution for this. Your thoughts please.