How can I determine if MS Office 2007 SP2 is installed?
In am using MS Word via OLE to produce documents from my 开发者_JS百科application. I want to give the users that have MS Office 2007 SP2 installed the ability to save the documents as PDF. This is only available in SP2, and the option should be hidden if the service pack is not installed (and of course also for users of previous versions of MS Office).
Is this information available anywhere, like in the registry or any configuration file?
Couldn't find anything helpful for you but here is something which you might find useful.
Office version is stored in registry
HKEY_LOCAL_MACHINE \Software\Microsoft\Office\12.0\Common\productVersion
the value 12.0 changes for office 2003 and 2007. This key has a number. I think checking this number for different version (with/without SP1/SP2) and see if there sia difference.
For the actual version infos that apply to the individual service packs have a look at this well hidden kb entry:
http://support.microsoft.com/kb/928116
There are different plugins from Microsoft to provide the print to PDF feature:
- 2007 Microsoft Office Add-in: Microsoft Save as PDF or XPS
- 2007 Microsoft Office Add-in: Microsoft Save as PDF
- 2007 Microsoft Office Add-in: Microsoft Save as XPS (does NOT come with PDF support)
and SP2 installs these Addins too.
I was looking for a way to test if the PDF feature is installed or not. The following file is only present if the PDF feature is installed (by an add-in or by the SP) on a machine:
C:\Program Files\Common Files\Microsoft Shares\Office12\EXP_PDF.DLL
The update is installed in the following registry key.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\00002109030000000000000000F01FEC\Patches\6D6C63B08D5FFAE4FB4934672A03DAB5
Ok, this is a bit late but you can determine the Service pack directly from VBA without having to mess with the registry. Obviously you'd need to update it as Microsoft updates Office.
Using the support pages for the different versions off Office you can get the build number and use a function to determine the service pack etc. Office 2007 shows slight discrepancies between the different applications within office so you'd have to tweak as required.
- Office 2007: http://support.microsoft.com/kb/928116
- Office 2010: http://support.microsoft.com/kb/2687455 (half way down the page describes the build numbers)
Then a function as follows will do the job for Excel Office 2007+:
Function DetermineExcelServicePack() As String
Dim sReturn As String
If Application.Version = "12.0" Then
If Application.Build < 6214 Then
sReturn = "Excel 2007, RTM"
ElseIf Application.Build < 6425 Then
sReturn = "Excel 2007, SP1"
ElseIf Application.Build < 6611 Then
sReturn = "Excel 2007, SP2"
Else
sReturn = "Excel 2007, SP3"
End If
ElseIf Application.Version = "14.0" Then
If Application.Build < 6029 Then
sReturn = "Excel 2010, RTM"
ElseIf Application.Build < 7015 Then
sReturn = "Excel 2010, SP1"
Else
sReturn = "Excel 2010, SP2"
End If
ElseIf Application.Version = "15.0" Then
sReturn = "Excel 2013, RTM"
Else
sReturn = "This version (" & Application.Version & "-" & Application.Build & ") is not supported by this function"
End If
DetermineExcelServicePack = sReturn
End Function
Programatically check whether version of the MSO.DLL file is greater than or equal to :
"12.0.6425.1000"
This is the value for the file if SP2 and above is installed.
精彩评论