Write the function code in the new module:
Function VersiOffice(ByVal Aplikasi As String) As String
On Error GoTo Ero
Dim Reg As Object
Dim s As String
Set Reg = CreateObject("Wscript.Shell")
s = Reg.RegRead("HKCR\" & Aplikasi & ".Application\CurVer\")
VersiOffice = Replace(s, Aplikasi & ".Application.", "", , , 1)
Ero:
End Function
On Error GoTo Ero
Dim Reg As Object
Dim s As String
Set Reg = CreateObject("Wscript.Shell")
s = Reg.RegRead("HKCR\" & Aplikasi & ".Application\CurVer\")
VersiOffice = Replace(s, Aplikasi & ".Application.", "", , , 1)
Ero:
End Function
Use code like this:
Dim v As String
v = VersiOffice("Word")
If v <> "" Then
MsgBox ("Microsoft Word versi " & v)
Else
MsgBox ("Microsoft Word tidak ter-install")
End If
v = VersiOffice("Word")
If v <> "" Then
MsgBox ("Microsoft Word versi " & v)
Else
MsgBox ("Microsoft Word tidak ter-install")
End If
Can be seen in the example above is used to detect the Word, then it can also be used to Excel, PowerPoint, Access, etc.
0 comments:
Post a Comment