colinardo
Goto Top

Herausfinden ob eine Microsoft Office Anwendung installiert ist (mit VBS bzw. VBA)

Diese Frage müssen sich Programmierer immer mal wieder stellen: "Wie kriege ich raus ob eine Office-Anwendung installiert ist?". Dafür gibt es wie immer mehrere Wege die zum Ziel führen. Für alle die schnell eine Lösung dafür benötigen habe ich zwei Funktionen bereitgestellt mit denen diese Abfrage komfortabel in VBS /VBA gelöst werden kann. Viele Anleitungen im Web bieten immer nur Lösungen für die Abfrage einzelner Office Anwendungen. Diese Lösung kombiniert alle möglichen Applikationen für Office 2003, 2007 und 2010 in zwei Funktionen.

back-to-topUm die unten aufgeführten Funktionen zu nutzen kann z.B. folgender Code benutzt werden:
If isOffice2010AppInstalled("Microsoft Office Professional Plus 2010") Then  
	'App is installed  
	WScript.Echo "Microsoft Office Professional Plus 2010 ist installiert."  
Else
	'App is not installed  
	WScript.Echo "Microsoft Office Professional Plus 2010 ist nicht installiert."  
End If

back-to-topAls Parameter der Funktionen muss der Name der Office-Anwendung angegeben werden für die überprüft werden soll ob sie installiert ist. Die möglichen Werte für diesen Parameter sind unter den Funktionen aufgelistet. Die Rückgabewerte der Funktionen sind TRUE (-1) bei vorhandener Installation der Anwendung und FALSE (0) falls nicht.


back-to-topFunktion für Office 2003
Function isOffice2003AppInstalled(appname)
	Set objRegistry = GetObject("winmgmts:\\.\root\default:StdRegProv")  
	Dim productID,appInstalled,appReg,osArch
        const HKEY_LOCAL_MACHINE = &H80000002
	Dim appRegSubkeys()
        appInstalled = False
	
        Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")  
        Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")  
        For Each objOS in colOSes
           osArch = objOS.OSArchitecture
        Next
	
	If osArch = "64-Bit" Then  
		appReg = "Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"  
	Else
		appReg = "Software\Microsoft\Windows\CurrentVersion\Uninstall"  
	End If
	
	Select Case appname
		Case "Microsoft Office Professional Enterprise Edition 2003"  
		productID = "11"  
		Case "Microsoft Office Standard Edition 2003"  
		productID = "12"  
		Case "Microsoft Office Basic Edition 2003"  
		productID = "13"  
		Case "Microsoft Windows SharePoint Services 2.0"  
		productID = "14"  
		Case "Microsoft Office Access 2003"  
		productID = "15"  
		Case "Microsoft Office Excel 2003"  
		productID = "16"  
		Case "Microsoft Office FrontPage 2003"  
		productID = "17"  
		Case "Microsoft Office PowerPoint 2003"  
		productID = "18"  
		Case "Microsoft Office Publisher 2003"  
		productID = "19"  
		Case "Microsoft Office Outlook Professional 2003"  
		productID = "1A"  
		Case "Microsoft Office Word 2003"  
		productID = "1B"  
		Case "Microsoft Office Access 2003-Laufzeit"  
		productID = "1C"  
		Case "Microsoft Office 2003 User Interface Pack"  
		productID = "1E"  
		Case "Microsoft Office 2003-Korrekturhilfen"  
		productID = "1F"  
		Case "Microsoft Office 2003 Multilingual User Interface Pack"  
		productID = "23"  
		Case "Microsoft Office 2003 Resource Kit"  
		productID = "24"  
		Case "Microsoft Office XP-Webkomponenten"  
		productID = "26"  
		Case "Microsoft Office 2003 Research Service SDK"  
		productID = "2E"  
		Case "Microsoft Office InfoPath 2003"  
		productID = "44"  
		Case "Microsoft Office 2003 HTML Viewer"  
		productID = "83"  
		Case "Windows SharePoint Services 2.0 Template Pack (Englisch)"  
		productID = "92"  
		Case "Microsoft Office 2003 Webparts und -komponenten (Englisch)"  
		productID = "93"  
		Case "Microsoft Office OneNote 2003"  
		productID = "A1"  
		Case "Microsoft Office 2003-Webkomponenten"  
		productID = "A4"  
		Case "Microsoft SharePoint Migration Tool 2003"  
		productID = "A5"  
		Case "Microsoft Office PowerPoint 2003 Präsentationsübertragung"  
		productID = "AA"  
		Case "Microsoft Office PowerPoint 2003 Template Pack 1"  
		productID = "AB"  
		Case "Microsoft Office PowerPoint 2003 Template Pack 2"  
		productID = "AC"  
		Case "Microsoft Office PowerPoint 2003 Template Pack 3"  
		productID = "AD"  
		Case "Microsoft Organigramm 2.0"  
		productID = "AE"  
		Case "Microsoft Office Small Business Edition 2003"  
		productID = "CA"  
		Case "Microsoft Office Access 2003 Developer Extensions"  
		productID = "D0"  
		Case "Microsoft Office 2003 Smart Document SDK"  
		productID = "DC"  
		Case "Microsoft Office Outlook Standard 2003"  
		productID = "E0"  
		Case "Microsoft Office Professional Edition 2003 (mit InfoPath 2003)"  
		productID = "E3"  
		Case "Microsoft Office Outlook 2003 (verteilt von MSN)"  
		productID = "FD"  
		Case "Microsoft Office 2003 User Interface Pack-Edition"  
		productID = "FF"  
		Case "Tool zum Entfernen verborgener Daten"  
		productID = "F8"  
		Case "Microsoft Office Project Standard 2003"  
		productID = "3A"  
		Case "Microsoft Office Project Professional 2003"  
		productID = "3B"  
		Case "Microsoft Office Project Server 2003"  
		productID = "32"  
		Case "Microsoft Office Visio Professional 2003"  
		productID = "51"  
		Case "Microsoft Office Visio Standard 2003"  
		productID = "53"  
		Case "Microsoft Office Visio 2003 Multilingual User Interface Pack"  
		productID = "5E"  
	End Select
	Set myRegExp = New RegExp
	myRegExp.Pattern = "^{9(0|1|2)" & productID & "[0-9A-F]{4}-.*}"  
	objRegistry.EnumKey HKEY_LOCAL_MACHINE,appReg,appRegSubkeys
	For Each subkey In appRegSubkeys
		Set myMatches = myRegExp.Execute(subkey)
		If myMatches.Count >= 1 Then
			'Office App is installed  
			appInstalled = True
		End If
	Next
	If appInstalled Then
		isOffice2003AppInstalled = True
	Else
		isOffice2003AppInstalled = False
	End if
	Set objRegistry = Nothing
End Function
back-to-topMögliche Anwendungsnamen als Parameter der Funktion:
  • Microsoft Office Professional Enterprise Edition 2003
  • Microsoft Office Standard Edition 2003
  • Microsoft Office Basic Edition 2003
  • Microsoft Windows SharePoint Services 2.0
  • Microsoft Office Access 2003
  • Microsoft Office Excel 2003
  • Microsoft Office FrontPage 2003
  • Microsoft Office PowerPoint 2003
  • Microsoft Office Publisher 2003
  • Microsoft Office Outlook Professional 2003
  • Microsoft Office Word 2003
  • Microsoft Office Access 2003-Laufzeit
  • Microsoft Office 2003 User Interface Pack
  • Microsoft Office 2003-Korrekturhilfen
  • Microsoft Office 2003 Multilingual User Interface Pack
  • Microsoft Office 2003 Resource Kit
  • Microsoft Office XP-Webkomponenten
  • Microsoft Office 2003 Research Service SDK
  • Microsoft Office InfoPath 2003
  • Microsoft Office 2003 HTML Viewer
  • Windows SharePoint Services 2.0 Template Pack (Englisch)
  • Microsoft Office 2003 Webparts und -komponenten (Englisch)
  • Microsoft Office OneNote 2003
  • Microsoft Office 2003-Webkomponenten
  • Microsoft SharePoint Migration Tool 2003
  • Microsoft Office PowerPoint 2003 Präsentationsübertragung
  • Microsoft Office PowerPoint 2003 Template Pack 1
  • Microsoft Office PowerPoint 2003 Template Pack 2
  • Microsoft Office PowerPoint 2003 Template Pack 3
  • Microsoft Organigramm 2.0
  • Microsoft Office Small Business Edition 2003
  • Microsoft Office Access 2003 Developer Extensions
  • Microsoft Office 2003 Smart Document SDK
  • Microsoft Office Outlook Standard 2003
  • Microsoft Office Professional Edition 2003 (mit InfoPath 200
  • Microsoft Office Outlook 2003 (verteilt von MSN)
  • Microsoft Office 2003 User Interface Pack-Edition
  • Tool zum Entfernen verborgener Daten
  • Microsoft Office Project Standard 2003
  • Microsoft Office Project Professional 2003
  • Microsoft Office Project Server 2003
  • Microsoft Office Visio Professional 2003
  • Microsoft Office Visio Standard 2003
  • Microsoft Office Visio 2003 Multilingual User Interface Pack

back-to-topFunktion für Office 2007
Function isOffice2007AppInstalled(appname)
	Set objRegistry = GetObject("winmgmts:\\.\root\default:StdRegProv")  
	Dim productID,appInstalled,appReg,osArch
        const HKEY_LOCAL_MACHINE = &H80000002
	Dim appRegSubkeys()
        appInstalled = False
	
        Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")  
        Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")  
        For Each objOS in colOSes
           osArch = objOS.OSArchitecture
        Next

	If osArch = "64-Bit" Then  
		appReg = "Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"  
	Else
		appReg = "Software\Microsoft\Windows\CurrentVersion\Uninstall"  
	End If
	
	Select Case appname
		Case "Microsoft-Softwareupdate für Webordner (Englisch) 12"  
		productID = "0010"  
		Case "Microsoft Office Professional Plus 2007"  
		productID = "0011"  
		Case "Microsoft Office Standard 2007"  
		productID = "0012"  
		Case "Microsoft Office Basic 2007"  
		productID = "0013"  
		Case "Microsoft Office Professional 2007"  
		productID = "0014"  
		Case "Microsoft Office Access 2007"  
		productID = "0015"  
		Case "Microsoft Office Excel 2007"  
		productID = "0016"  
		Case "Microsoft Office SharePoint Designer 2007"  
		productID = "0017"  
		Case "Microsoft Office PowerPoint 2007"  
		productID = "0018"  
		Case "Microsoft Office Publisher 2007"  
		productID = "0019"  
		Case "Microsoft Office Outlook 2007"  
		productID = "001A"  
		Case "Microsoft Office Word 2007"  
		productID = "001B"  
		Case "Microsoft Office Access Runtime 2007"  
		productID = "001C"  
		Case "Microsoft Office Compatibility Pack für Word, Excel und PowerPoint 2007-Dateiformate"  
		productID = "0020"  
		Case "Microsoft Expression Web"  
		productID = "0026"  
		Case "Microsoft Office Ultimate 2007"  
		productID = "002E"  
		Case "Microsoft Office Home and Student 2007"  
		productID = "002F"  
		Case "Microsoft Office Enterprise 2007"  
		productID = "0030"  
		Case "Microsoft Office Professional Hybrid 2007"  
		productID = "0031"  
		Case "Microsoft Office Personal 2007"  
		productID = "0033"  
		Case "Microsoft Office Professional Hybrid 2007"  
		productID = "0035"  
		Case "Microsoft Office Project Standard 2007"  
		productID = "003A"  
		Case "Microsoft Office Project Professional 2007"  
		productID = "003B"  
		Case "Microsoft Office InfoPath 2007"  
		productID = "0044"  
		Case "Microsoft Office Visio Professional 2007"  
		productID = "0051"  
		Case "Microsoft Office Visio Viewer 2007"  
		productID = "0052"  
		Case "Microsoft Office Visio Standard 2007"  
		productID = "0053"  
		Case "Microsoft Office OneNote 2007"  
		productID = "00A1"  
		Case "Microsoft Office OneNote Home Student 2007"  
		productID = "00A3"  
		Case "Kalenderdruck-Assistent für Microsoft Office Outlook 2007"  
		productID = "00A7"  
		Case "Microsoft Office InterConnect 2007"  
		productID = "00A9"  
		Case "Microsoft Office PowerPoint Viewer 2007 (Englisch)"  
		productID = "00AF"  
		Case "Die Microsoft-Save als PDF-add-in"  
		productID = "00B0"  
		Case "Die Microsoft-Save als XPS-add-in"  
		productID = "00B1"  
		Case "Die Microsoft-Save als PDF- oder XPS-add-in"  
		productID = "00B2"  
		Case "Microsoft Office Groove 2007"  
		productID = "00BA"  
		Case "Microsoft Office Small Business 2007"  
		productID = "00CA"  
		Case "Microsoft Office Access-Datenbankmodul 2007 (Englisch)"  
		productID = "00D1"  
		Case "Microsoft Office InfoPath Forms Services"  
		productID = "10D7"  
		Case "Microsoft Office SharePoint Server 2007"  
		productID = "110D"  
		Case "Windows SharePoint Services-Ressourcen für Entwickler 1.2"  
		productID = "1122"  
	End Select
	Set myRegExp = New RegExp
	myRegExp.Pattern = "^{9(0|1|2)120000-" & productID & "-[0-9A-F]{4}-(0|1)000-0000000FF1CE}$"  
	objRegistry.EnumKey HKEY_LOCAL_MACHINE,appReg,appRegSubkeys
	For Each subkey In appRegSubkeys
		Set myMatches = myRegExp.Execute(subkey)
		If myMatches.Count >= 1 Then
			'Office App is installed  
			appInstalled = True
		End If
	Next
	If appInstalled Then
		isOffice2007AppInstalled = True
	Else
		isOffice2007AppInstalled = False
	End if
	Set objRegistry = Nothing
End Function

back-to-topMögliche Anwendungsnamen als Parameter der Funktion:
  • Microsoft-Softwareupdate für Webordner (Englisch) 12
  • Microsoft Office Professional Plus 2007
  • Microsoft Office Standard 2007
  • Microsoft Office Basic 2007
  • Microsoft Office Professional 2007
  • Microsoft Office Access 2007
  • Microsoft Office Excel 2007
  • Microsoft Office SharePoint Designer 2007
  • Microsoft Office PowerPoint 2007
  • Microsoft Office Publisher 2007
  • Microsoft Office Outlook 2007
  • Microsoft Office Word 2007
  • Microsoft Office Access Runtime 2007
  • Microsoft Office Compatibility Pack für Word, Excel und PowerPoint 2007-Dateiformate
  • Microsoft Expression Web
  • Microsoft Office Ultimate 2007
  • Microsoft Office Home and Student 2007
  • Microsoft Office Enterprise 2007
  • Microsoft Office Professional Hybrid 2007
  • Microsoft Office Personal 2007
  • Microsoft Office Professional Hybrid 2007
  • Microsoft Office Project Standard 2007
  • Microsoft Office Project Professional 2007
  • Microsoft Office InfoPath 2007
  • Microsoft Office Visio Professional 2007
  • Microsoft Office Visio Viewer 2007
  • Microsoft Office Visio Standard 2007
  • Microsoft Office OneNote 2007
  • Microsoft Office OneNote Home Student 2007
  • Kalenderdruck-Assistent für Microsoft Office Outlook 2007
  • Microsoft Office InterConnect 2007
  • Microsoft Office PowerPoint Viewer 2007 (Englisch)
  • Die Microsoft-Save als PDF-add-in
  • Die Microsoft-Save als XPS-add-in
  • Die Microsoft-Save als PDF- oder XPS-add-in
  • Microsoft Office Groove 2007
  • Microsoft Office Small Business 2007
  • Microsoft Office Access-Datenbankmodul 2007 (Englisch)
  • Microsoft Office InfoPath Forms Services
  • Microsoft Office SharePoint Server 2007
  • Windows SharePoint Services-Ressourcen für Entwickler 1.2

back-to-topFunktion für Office 2010
Function isOffice2010AppInstalled(appname)
	Set objRegistry = GetObject("winmgmts:\\.\root\default:StdRegProv")  
	Dim productID,appInstalled,appReg,osArch
	const HKEY_LOCAL_MACHINE = &H80000002
	appInstalled = False
	Dim appRegSubkeys()

	Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")  
        Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")  
        For Each objOS in colOSes
           osArch = objOS.OSArchitecture
        Next

	If osArch = "64-Bit" Then  
		appReg = "Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"  
	Else
		appReg = "Software\Microsoft\Windows\CurrentVersion\Uninstall"  
	End If

	Select Case appname
		Case "Microsoft Office Professional Plus 2010"  
			productID = "0011"  
		Case "Microsoft Office Standard 2010"  
			productID = "0012"  
		Case "Microsoft Office Home and Business 2010"  
			productID = "0013"  
		Case "Microsoft Office Professional 2010"  
			productID = "0014"  
		Case "Microsoft Access 2010"  
			productID = "0015"  
		Case "Microsoft Excel 2010"  
			productID = "0016"  
		Case "Microsoft SharePoint Designer 2010"  
			productID = "0017"  
		Case "Microsoft PowerPoint 2010"  
			productID = "0018"  
		Case "Microsoft Publisher 2010"  
			productID = "0019"  
		Case "Microsoft Outlook 2010"  
			productID = "001A"  
		Case "Microsoft Word 2010"  
			productID = "001B"  
		Case "Microsoft Access Runtime 2010"  
			productID = "001C"  
		Case "Microsoft Office Proofing Tools Kit Compilation 2010"  
			productID = "001F"  
		Case "Microsoft Office Home and Student 2010"  
			productID = "002F"  
		Case "Microsoft Project Standard 2010"  
			productID = "003A"  
		Case "Microsoft Project Professional 2010"  
			productID = "003B"  
		Case "Microsoft InfoPath 2010"  
			productID = "0044"  
		Case "Microsoft Visio Viewer 2010"  
			productID = "0052"  
		Case "Microsoft Visio 2010"  
			productID = "0057"  
		Case "Microsoft Outlook Connector"  
			productID = "007A"  
		Case "Microsoft Office Small Business Basics 2010"  
			productID = "008B"  
		Case "Microsoft OneNote 2010"  
			productID = "00A1"  
		Case "Microsoft PowerPoint Viewer 2010"  
			productID = "00AF"  
		Case "Microsoft Office SharePoint Workspace 2010"  
			productID = "00BA"  
		Case "Microsoft Office SharePoint Server 2010"  
			productID = "110D"  
		Case "Microsoft Project Server 2010"  
			productID = "110F"  
	End Select
	
	Set myRegExp = New RegExp
	myRegExp.Pattern = "^{9(0|1|2|5)140000-" & productID & "-[0-9A-F]{4}-(0|1)000-0000000FF1CE}$"  
	objRegistry.EnumKey HKEY_LOCAL_MACHINE,appReg,appRegSubkeys
	For Each subkey In appRegSubkeys
		Set myMatches = myRegExp.Execute(subkey)
		If myMatches.Count >= 1 Then
			'Office App is installed  
			appInstalled = True
		End If
	Next
	If appInstalled Then
		isOffice2010AppInstalled = True
	Else
		isOffice2010AppInstalled = False
	End if
        Set objRegistry = Nothing
End Function
back-to-topMögliche Anwendungsnamen als Parameter der Funktion:
  • Microsoft Office Professional Plus 2010
  • Microsoft Office Standard 2010
  • Microsoft Office Home and Business 2010
  • Microsoft Office Professional 2010
  • Microsoft Access 2010
  • Microsoft Excel 2010
  • Microsoft SharePoint Designer 2010
  • Microsoft PowerPoint 2010
  • Microsoft Publisher 2010
  • Microsoft Outlook 2010
  • Microsoft Word 2010
  • Microsoft Access Runtime 2010
  • Microsoft Office Proofing Tools Kit Compilation 2010
  • Microsoft Office Home and Student 2010
  • Microsoft Project Standard 2010
  • Microsoft Project Professional 2010
  • Microsoft InfoPath 2010
  • Microsoft Visio Viewer 2010
  • Microsoft Visio 2010
  • Microsoft Outlook Connector
  • Microsoft Office Small Business Basics 2010
  • Microsoft OneNote 2010
  • Microsoft PowerPoint Viewer 2010
  • Microsoft Office SharePoint Workspace 2010
  • Microsoft Office SharePoint Server 2010
  • Microsoft Project Server 2010
----

Grüße colinardo

Content-ID: 204951

Url: https://administrator.de/tutorial/herausfinden-ob-eine-microsoft-office-anwendung-installiert-ist-mit-vbs-bzw-vba-204951.html

Ausgedruckt am: 24.12.2024 um 13:12 Uhr

rubberman
rubberman 16.04.2013 um 18:56:43 Uhr
Goto Top
Hallo colinardo,

gut gemacht face-smile
Zu ...
If osEnv("PROCESSOR_ARCHITECTURE") = "AMD64" Then 
... habe ich aber meine Bedenken. Zum einen solltest du per InStr() Funktion lediglich nach "64" suchen, zum anderen sagt der Prozessor nicht zwingend etwas über das Betriebssystem aus.
Alternativ könntest du in der WMI Klasse "Win32_OperatingSystem" die 64 im Wert für "CreationClassName" oder "OSArchitecture" suchen.

Übrigens hat M$ selbst ein mehrere tausend Zeilen langes Script zu diesem Zweck veröffentlicht:
Robust Office Inventory Scan Tool (ROISCAN)

Grüße
rubberman
colinardo
colinardo 16.04.2013 aktualisiert um 21:07:51 Uhr
Goto Top
Hi rubberman,
danke für deine Rückmeldung, Werde die 64Bit-Abfrage noch umbauen.Ist bereits korrigiert.
Danke auch für den Link, das Script kannte ich noch nicht.
Grüße Uwe