2019年6月17日 星期一

Excel VBA:Excel 資訊查詢

有時候要在Excel VBA查詢關於Excel本身的資訊,可透過以下幾行程式就能做到。
Sub Excel資訊()
    Excelver = Array("8.0", "9.0", "10.0", "11.0", "12.0", "14.0", "15.0", "16.0")
    vername = Array("97", "2000", "2002", "2003", "2007", "2010", "2013", "2016 或 365")
    For i = 0 To UBound(Excelver)
        If Excelver(i) = Application.Version Then
            MsgBox "目前 Excel 版本:Excel" & vername(i)
            Exit For
        End If
    Next
    
    With CreateObject("Excel.Application")
        MsgBox "Excel.EXE 路徑 = " + .Path
    End With
End Sub

沒有留言:

張貼留言