Loay hoay cái vụ này mãi, tìm thấy đuwocj cái này trên mạng. Topic này cũng lâu rồi nhưng mình vẫn post lên xem nếu ai có cần thì dùng:
Tham khảo từ
http://www.excelguru.ca/node/58/print
Code
Sub CheckVBA_Access()
Dim WSS As Object, strKey As String
Set WSS = CreateObject("WScript.Shell")
'key to modify
strKey = "HKEY_LOCAL_MACHINE\Software\Microsoft\Office\" & _
Application.Version & "\Excel\Security\AccessVBOM"
'enable access
WSS.RegWrite strKey, 1, "REG_DWORD"
'read the vba project name
MsgBox ActiveWorkbook.VBProject.Name
'disable access
WSS.RegDelete strKey
End Sub
By Ken Puls
Created 2006-08-31 08:23
Code to check access
Code to check access
Function IsVBATrusted() As Boolean
Dim VBC As Object
Application.DisplayAlerts = False
On Error Resume Next
Set VBC = ThisWorkbook.VBProject.VBComponents.Item(1)
On Error Goto 0
Application.DisplayAlerts = True
IsVBATrusted = Not VBC Is Nothing
End Function