检测已安装的Excel版本(和Service Pack) [英] Detecting Installed Excel Version (and Service Packs)

查看:121
本文介绍了检测已安装的Excel版本(和Service Pack)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够从我正在开发的一些.NET代码中检测我的机器中安装的哪个版本的Excel。我目前正在使用 Application.Version ,但不提供有关Service Pack的信息。

I need to be able to detect which version of Excel I have installed in my machine from some .NET code I'm developing. I'm currently using Application.Version for that, but it doesn't give me information about Service Packs.

我最好指导远离这样的事情:
http://www.mvps.org/ access / api / api0065.htm

I would preferably to steer away from something like this: http://www.mvps.org/access/api/api0065.htm

欢迎托管代码

推荐答案

Public Shared Function GetExcelVersion() As Integer
    Dim excel As Object = Nothing
    Dim ver As Integer = 0
    Dim build As Integer
    Try
        excel = CreateObject("Excel.Application")
        ver = excel.Version
        build = excel.Build
    Catch ex As Exception
        'Continue to finally sttmt
    Finally
        Try
            Marshal.ReleaseComObject(excel)
        Catch
        End Try
        GC.Collect()
    End Try
    Return ver
End Function

如果找不到excel,则返回0。

Returns 0 if excel not found.

这篇关于检测已安装的Excel版本(和Service Pack)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆