wiklendt
i recommend chocolate
- Local time
- Tomorrow, 08:39
- Joined
- Mar 10, 2008
- Messages
- 1,746
hi everyone,
i adapted some code from Ken Higg's FE loader code in order to open an excel file (his was to open an access FE). this works fabulously, but now i need to update it to use whichever excel version is installed (folder path for 2007 includes "Office12", while all previous versions are "Office11", as far as i can tell).
i can do this by manually changing the constant, but have had no luck working it using VBA.
this is what i have:
i just comment out whichever one is appropriate, but i'd like it to be automatic especially seeing as one day i might not be working in the same company and they'll one day upgrade to excel 2007 (or higher) and i want to my DB work!
i changed the "Const" to:
but it causes the button press to have no effect (with no error either). i've tried a few variations on the theme, including this additional code (and colourful variations thereof):
but no luck. it seems that if there is anything after "Const" that is different from the single path then it just flatlines.
can anyone help here?
i adapted some code from Ken Higg's FE loader code in order to open an excel file (his was to open an access FE). this works fabulously, but now i need to update it to use whichever excel version is installed (folder path for 2007 includes "Office12", while all previous versions are "Office11", as far as i can tell).
i can do this by manually changing the constant, but have had no luck working it using VBA.
this is what i have:
Code:
If intAnswer = vbYes Then 'open the excel file for the user
'Location of MS Excel .exe (versions prior to Excel 2007)
Const cstrMSExcelAPP = "C:\Program Files\Microsoft Office\Office11\EXCEL.exe"
'Location of MS Excel .exe (Excel 2007 version)
'Const cstrMSExcelAPP = "C:\Program Files\Microsoft Office\Office12\EXCEL.exe"
Dim intX As Integer 'Utility var
Dim strCommandLine As String 'Application to run and file to open
'Build string
strCommandLine = cstrMSExcelAPP & " /cmd " & Chr(34) & strExportFile & Chr(34)
'Open exported excel file
intX = Shell(strCommandLine, 3)
Else
Exit Sub
End If
i just comment out whichever one is appropriate, but i'd like it to be automatic especially seeing as one day i might not be working in the same company and they'll one day upgrade to excel 2007 (or higher) and i want to my DB work!
i changed the "Const" to:
Code:
Const cstrMSExcelAPP = Nz(Dir("C:\Program Files\Microsoft Office\Office11\EXCEL.exe"), "C:\Program Files\Microsoft Office\Office12\EXCEL.exe")
but it causes the button press to have no effect (with no error either). i've tried a few variations on the theme, including this additional code (and colourful variations thereof):
Code:
Dim strExcelPath, strExcelPath1, strExcelPath2 As String
'path for versions 2003 or earlier
strExcelPath1 = "C:\Program Files\Microsoft Office\Office11\EXCEL.exe"
'path for versions 2007 or later
strExcelPath2 = "C:\Program Files\Microsoft Office\Office12\EXCEL.exe"
If IsNull(Dir(strExcelPath1)) Then
If IsNull(Dir(strExcelPath2)) Then
MsgBox "Microsoft Excel not found. Cannot open file."
Else
strExcelPath = strExcelPath2
End If
Else
strExcelPath = strExcelPath1
End If
'Location of MS Excel .exe
Const cstrMSExcelAPP = strExcelPath
but no luck. it seems that if there is anything after "Const" that is different from the single path then it just flatlines.
can anyone help here?