在vb里定义
dim ss as word
看能不能行,不行就是没装上

解决方案 »

  1.   

    假如装了,没有引用还是一样我是想在程序中判断,假如装了,就用EXCEL生成报表。
      

  2.   

    我正在做一个安装程序,其中就有判断是否安装了某一个软件的问题
    正常的步骤是:
    1.在注册表里面找该软件的执行程序的Key,根据该Key取出一个完全的路径
    2.根据取出的路径在硬盘上找一下,看看是否确实有该程序如果没有软件的执行程序的Key,或者有Key,硬盘上没有对应的文件,就认为是没有安装的
      

  3.   

    to ozw:
    能不能贴点程序啊?hehe
      

  4.   

    比如监测是否安装了EXCEL 2000
      

  5.   

            Dim aa As String
            Dim word As String
            regk = "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe"
            regv = "PATH"
            If GetKeyValue(HKEY_LOCAL_MACHINE, regk, regv, word) Then
                
                If Right(word, 1) = "\" Then
                word = word & "winword.exe"
                Else
                word = word & "\winword.exe"
                End If
                If Dir(word) <> "" Then
                    Call Shell(word, vbMaximizedFocus)
                Else
                    MsgBox "&Auml;ú&micro;&Auml;&micro;&ccedil;&Auml;&Ocirc;&raquo;&sup1;&Atilde;&raquo;&Oacute;&ETH;°&sup2;×°Microsoft Word&raquo;òWord&Icirc;&Auml;&frac14;&thorn;&Ograve;&Ntilde;&Euml;&eth;&raquo;&micro;&pound;&not;&Ccedil;&euml;&Oacute;&euml;&micro;&ccedil;&Auml;&Ocirc;&Egrave;&Euml;&Ocirc;±&Aacute;&ordf;&Iuml;&micro;&iexcl;&pound;", vbOKOnly
                End If
            Else
                MsgBox "&Auml;ú&micro;&Auml;&micro;&ccedil;&Auml;&Ocirc;&raquo;&sup1;&Atilde;&raquo;&Oacute;&ETH;°&sup2;×°Microsoft Word&raquo;òWord&Icirc;&Auml;&frac14;&thorn;&Ograve;&Ntilde;&Euml;&eth;&raquo;&micro;&pound;&not;&Ccedil;&euml;&Oacute;&euml;&micro;&ccedil;&Auml;&Ocirc;&Egrave;&Euml;&Ocirc;±&Aacute;&ordf;&Iuml;&micro;&iexcl;&pound;", vbOKOnly
            End If我这段代码你可以看看。我这里已经是直接启动WORD的啦。
    不过我不知道为什么我的程序中的中文在这里会变成乱码的。
      

  6.   

    Dim appGas As Variant
    Set appGas = CreateObject("word.Application")
      

  7.   

    为什么非要去读注册表判断呢??那程序执行起来不是慢的要死啊!!!
    直接定义变量,看它能不能引用不就行了吗!!
    dim ss as word.document
      

  8.   

    我是给你贴VB程序呢,还是贴InstallShield的Script呢?
      

  9.   


    '=========================================================='
    '                     API Declarations                     '
    '=========================================================='
    Public Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
    Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long         ' Note that if you declare the lpData parameter as String, you must pass it By Value.
    Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long         ' Note that if you declare the lpData parameter as String, you must pass it By Value.
    Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    Public Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
    Public Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
    Public Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long'=========================================================='
    '                      public Structs                     '
    '=========================================================='
    Public Type OSVERSIONINFO
        dwOSVersionInfoSize As Long
        dwMajorVersion As Long
        dwMinorVersion As Long
        dwBuildNumber As Long
        dwPlatformId As Long
        szCSDVersion As String * 128      '  Maintenance string for PSS usage
    End Type'=========================================================='
    '                   public Enumerations                   '
    '=========================================================='
    Public Enum OSVersions
        VER_PLATFORM_WIN32_NT = 2
        VER_PLATFORM_WIN32_WINDOWS = 1
        VER_PLATFORM_WIN32s = 0
    End Enum
    '=========================================================='
    '                   public Enumerations                    '
    '=========================================================='
    Public Enum hKey
        HKEY_CLASSES_ROOT = &H80000000
        HKEY_CURRENT_USER = &H80000001
        HKEY_LOCAL_MACHINE = &H80000002
        HKEY_USERS = &H80000003
        HKEY_CURRENT_CONFIG = &H80000005
        HKEY_DYN_DATA = &H80000006
    End EnumPublic Enum DataType
        KEY_NOTIFY = &H10
        READ_CONTROL = &H20000
        STANDARD_RIGHTS_READ = (READ_CONTROL)
        STANDARD_RIGHTS_WRITE = (READ_CONTROL)
        KEY_QUERY_VALUE = &H1
        KEY_SET_VALUE = &H2
        KEY_ENUMERATE_SUB_KEYS = &H8
        KEY_CREATE_SUB_KEY = &H4
        Synchronize = &H100000
        REG_SZ = 1            ' Unicode nul terminated string
        KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not Synchronize))
        KEY_WRITE = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY) And (Not Synchronize))
    End Enum
    ' Procedure retrieves a value from a key
    Public Function GetKeyStringValue(ByVal hKey As hKey, ByVal sLocation$, ByVal sKeyName$) As String
        Dim hwndKey&, sRecieved As String
        
        sRecieved = Space(255)
        
        If (RegOpenKeyEx(hKey, sLocation, 0, DataType.KEY_READ, hwndKey) = ERROR_SUCCESS) Then
        
            If (RegQueryValueEx(hwndKey, sKeyName, 0, DataType.REG_SZ, ByVal sRecieved, Len(sRecieved)) = ERROR_SUCCESS) Then
                GetKeyStringValue = TrimNull(sRecieved)
            Else
                GetKeyStringValue = ""
            End If        RegCloseKey hwndKey
        End If
    End Function
    ' Function removes the extra space from the string starting from the nullchar
    Public Function TrimNull(ByVal szNull As String) As String
        Dim m%
        
        m = InStr(szNull, Chr$(0))
        If (m) Then                                 ' Win95 puts adds a null value
            TrimNull = Mid$(szNull, 1, m - 1)
            
        Else
            TrimNull = ""                           ' WinNT does not add a nullchar
        End If
    End Function然后,自己写个函数Function ProgramIsExist(ByVal ExeName As String) As String
        Dim FilePath As String
    '    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Excel.exe]    FilePath = GetKeyStringValue(hKey.HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" & ExeName, "Path")
        
        If Dir(FilePath & "\" & ExeName) <> "" Then
            Debug.Print Dir(FilePath & "\" & ExeName)
            ProgramIsExist = True
        Else
            ProgramIsExist = False
        End If
        
    End FunctionPrivate Sub Form_Load()
        MsgBox ProgramIsExist("Excel.exe")
    End Sub