---
title: "Finns Office 200 installerat..."
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/71998-finns-office-200-installerat"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "saw"
published: "2003-03-24T10:43:00.000Z"
updated: "2003-03-25T21:27:43.000Z"
replies: 6
views: 305
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/71998-finns-office-200-installerat"
---

# Finns Office 200 installerat...

## #1 — saw, 2003-03-24T10:43Z

Någon som har en kodsnut som kan kontrollera om:

1\. Office 2000 är installerad.
2\. Isf är Word, Excell och Access installerad.

Vore väldigt tacksam för hjälp

Permalänk: https://www.webforum.nu/p/71998

## #2 — niko, 2003-03-24T11:31Z

Om du bara undrar om Office-paketet går att automatisera i största allmänhet kan du kanske använda kod typ denna:

```
Public Function IsWordAvailable()
    Dim dummy As Object
    On Error GoTo Nope
    Set dummy = CreateObject("Word.Application")
    IsWordAvailable = True
    Set dummy = Nothing
    Exit Function
Nope:
    IsWordAvailable = False
End Function
```

 .. och motsvarande för Excel, Access .. OBS: Anropen är ganska "tunga" så du bör bara köra dem en gång tex när applikationen startar.

Om du letar efter en specifik version av Office så får du nog dyka ner i registret. *LOCAL_MACHINE\\Software\\Microsoft\\Office* är ett hett tips.

Står lite här: <http://www.microsoft.com/office/ork/xp/journ/prog0001.htm> (XP iofs).

Permalänk: https://www.webforum.nu/p/989688

## #3 — OveRRidE, 2003-03-24T12:12Z

Office 200? ;)

Jaja, jag vet. :OO

Permalänk: https://www.webforum.nu/p/989714

## #4 — saw, 2003-03-25T14:28Z

Det jag hittar på microsofts sida är:

Sub CheckOfficeXPInstalled()
   InstallRoot = System.PrivateProfileString("", \_
 "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Office\\10.0\\Common\\InstallRoot", \_
 "Path")
   If InstallRoot \<\> "" Then
     MsgBox "An Office XP Family Product is installed at " & InstallRoot
   End If
End Sub

Men jag får bara error hela tiden.
Jag försökte att dimma so här:
Dim System As String, InstallRoot As String
Men får "invalid qualifer" hela tiden.
Vad tror du?
Dessutom så tänker de bara på OfficeXP här, men fråga rör sig ju om Office 2000, någon skillnad?

Permalänk: https://www.webforum.nu/p/990459

## #5 — niko, 2003-03-25T16:10Z

Anledningen till att det inte funkar är att koden är VBA inte VB. Den är också specifik för XP.

Eventuellt kan du köra så här för Office 2000:

```
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" _
(ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const HKEY_CURRENT_USER = &H80000001

Private Sub Command1_Click()
    Dim keyhand As Long
    r = RegOpenKey(HKEY_LOCAL_MACHINE, "SoftWare\Microsoft\Office\9.0\Access", keyhand)
    If r = 0 Then
        'Access 2000 är installerat.
    Else
        'Access 2000 är inte installerat.
    End If
    r = RegOpenKey(HKEY_LOCAL_MACHINE, "SoftWare\Microsoft\Office\9.0\Excel", keyhand)
    If r = 0 Then
        'Excel 2000 är installerat.
    Else
        'Excel 2000 är inte installerat.
    End If
    ' osv osv
End Sub
```

Jag har ingen aning om det alltid funkar. Eller om registernycklarna alltid finns oberoende om komponenten är installerad. Du får prova.

Permalänk: https://www.webforum.nu/p/990574

## #6 — saw, 2003-03-25T21:16Z

Det ser ju bra ut, men pga att jag har OfficeXP så har jag svårt att testa. Jag skulle vilja att scriptet tog ifrån Office2000 och uppåt.

Så här har jag försökt, men det lyckas inte:

Dim keyhand As Long, r As String, strOK As Boolean, sMessage As String
strOK = False
    r = RegOpenKey(HKEY_LOCAL_MACHINE, "SoftWare\\Microsoft\\Office\\9.0\\Access", keyhand) Or RegOpenKey(HKEY_LOCAL_MACHINE, "SoftWare\\Microsoft\\Office\\10.0\\Access", keyhand)
    If r = 0 Then
        strOK = True
        sMessage = "Access OK "
        'Access 2000 är installerat.
    Else
        'Access 2000 är inte installerat.
        strOK = False
        sMessage = "Ej Access  "
    End If
    r = RegOpenKey(HKEY_LOCAL_MACHINE, "SoftWare\\Microsoft\\Office\\9.0\\Excel", keyhand) Or RegOpenKey(HKEY_LOCAL_MACHINE, "SoftWare\\Microsoft\\Office\\10.0\\Excel", keyhand)
    If r = 0 Then
        strOK = True
        sMessage = sMessage & ",Excel OK "
        'Access 2000 är installerat.
    Else
        'Access 2000 är inte installerat.
        strOK = False
        sMessage = sMessage & ",Ej Excell  "
    End If
    
    If strOK = True Then
        Label2.Caption = "installerade Officeapplikationer: " & sMessage
    Else
        MsgBox "Office är inte installerad"
        Unload Me
        
    End If

Vad tror du?

Permalänk: https://www.webforum.nu/p/990821

## #7 — saw, 2003-03-25T21:27Z

Jag kom på det själv:

Dim keyhand As Long, r As String, t As String, strOK As Boolean, sMessage As String
strOK = False
    
    r = RegOpenKey(HKEY_LOCAL_MACHINE, "SoftWare\\Microsoft\\Office\\9.0\\Word", keyhand)
    t = RegOpenKey(HKEY_LOCAL_MACHINE, "SoftWare\\Microsoft\\Office\\10.0\\Word", keyhand)
    
    If r = 0 Or t = 0 Then
        strOK = True
        sMessage = " Word 2000 "
    Else
        strOK = False
        sMessage = " Ej Word  "
    End If

    r = RegOpenKey(HKEY_LOCAL_MACHINE, "SoftWare\\Microsoft\\Office\\9.0\\Access", keyhand)
    t = RegOpenKey(HKEY_LOCAL_MACHINE, "SoftWare\\Microsoft\\Office\\10.0\\Access", keyhand)
    
    If r = 0 Or t = 0 Then
        strOK = True
        sMessage = sMessage & ", Access 2000 "
    Else
        strOK = False
        sMessage = " Ej Access  "
    End If
    r = RegOpenKey(HKEY_LOCAL_MACHINE, "SoftWare\\Microsoft\\Office\\9.0\\Excel", keyhand)
    t = RegOpenKey(HKEY_LOCAL_MACHINE, "SoftWare\\Microsoft\\Office\\10.0\\Excel", keyhand)
    If r = 0 Or t = 0 Then
        strOK = True
        sMessage = sMessage & ", Excel 2000 "
    Else
        strOK = False
        sMessage = sMessage & ", Ej Excell  "
    End If
    
    If strOK = True Then
        Label2.Caption = "Installerade Office applikationer: " & sMessage
    Else
        MsgBox "Office är inte installerad"
        Unload Me
    End If

Tack för att du hjälpte mig

Permalänk: https://www.webforum.nu/p/990829

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/71998-finns-office-200-installerat
