Is there a way to determine the current version of Office other than to exhaustively look for directories Office11, Office12, Office14...........etc. Clearly advances in versions would render such searches as useless.
Is there a way to determine the current version of Office other than to exhaustively look for directories Office11, Office12, Office14...........etc. Clearly advances in versions would render such searches as useless.
Actually I'm wanting to know the directory for winword.exe, as my app needs to shell to word.
I use the Version property to determine the version of Access.
msgbox Application.Version
However, that is not a guarantee that Word is the same version. I would check for the existence of the directory. Maybe loop through iterations of a string to see if the directory exists. Maybe something like the following will bring the latest version\upgrade.
Code:dim strPath as string dim strOfficePath as string for i = 11 to 20 strPath = "Some\Directory\Office" & i & "\More stuff to find Word" If Dir(strPath, vbDirectory) > "" Then strOfficePath = strPath end if next i
Yes, I had already tested some code like what you've offered but had the concern that someday Microsoft would depart from the use of OFFICExx as their sub-directory of "Microsoft Office". I don't like sending apps out that have such exposures.
Thanks,
Bill
Yes, I had already tested some code like what you've offered but had the concern that someday Microsoft would depart from the use of OFFICExx as their sub-directory of "Microsoft Office". I don't like sending apps out that have such exposures.
Thanks,
Bill
I settled on this approach:
Code:Option Compare Database Option Explicit Private Sub TestFindPath() Dim strWORDexePath As String strWORDexePath = WORDpath() 'App wan'ts to open AandB.doc in WORD, so where is WORD? If strWORDexePath = "" Then MsgBox "Unable to locate Microsoft WORD application." & vbNewLine & _ "Please open WORD manually to file AandB.doc manually." Else MsgBox strWORDexePath End If End Sub Public Function WORDpath() As String '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* ' Nominal directory for Microsoft Office (32 bit version) is: ' "c:\Program Files (x86)\Microsoft Office\OFFICExx\" where "xx" corresponds to the version of Microsoft Office. ' We limit our search to that hierarchy beginning with Office 2003 (OFFICE11) and return a zero ' length string if WINWORD.EXE isn't found, letting using program decide what to do. '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* Dim I As Integer Dim strWORDpath As String Dim strTESTpath As String WORDpath = "" ' Return a zero length string if loop doesn't find WINWORD.exe For I = 11 To 20 strTESTpath = "c:\Program Files (x86)\Microsoft Office\Office" & I & "\winword.exe" strWORDpath = Dir(strTESTpath) If strWORDpath > "" Then WORDpath = strTESTpath ' Okay, we found it Exit For End If Next I End Function
Not sure you will be able to do much better than that. I believe you are trying to avoid late binding, but you could use late binding and open a hidden instance of Word. Then you could check the Object's .Version property. Maybe do something like this at time of setup and store the value in a table.
I think I'll let "sleeping dogs lie" at this point.
While the app has extensive facilities builtin to update back-end DB's in the filed with any version updates that affect DB structure, it would be easier to deal with field complaints in the unlikely event that Microsoft changes their directory hierarchy. I will update the code to also search "Program Files" should anyone happen to install a 64bit version of Office in the future.
Thanks,
Bill