Option Explicit

Dim objShell
Dim wshShell
Dim strComputer
Dim objRegistry
Dim fso



CreateKey("Software\Microsoft\Office\16.0\Access\Security\VBAWarnings")


Function CreateKey(strKey)
	If IsKeyExist("HKEY_CURRENT_USER\" & strKey) = false Then
		Const HKEY_CURRENT_USER = &H80000001
		
		strComputer = "."

		Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

		Set fso = CreateObject("Scripting.FileSystemObject")
		
		objRegistry.SetDWORDValue HKEY_CURRENT_USER, fso.GetParentFolderName(strKey), "VBAWarnings", 1
	End If
End Function

Function IsKeyExist(strKey)
	set wshShell= Wscript.CreateObject("WScript.Shell")
	on error resume next
	present = WshShell.RegRead(strKey)
	if err.number<>0 then
		if right(strKey,1)="\" then
			if instr(1,err.description,"Unable to open registry key",1)<>0 then
				IsKeyExist=true
			else
				IsKeyExist=false
			end if
		else
			IsKeyExist=false
		end if
		err.clear
	else
		IsKeyExist=true
	end if
	on error goto 0
End Function

''''''''''' MACRO WARNINGS '''''''''''
Set objShell = CreateObject("WScript.Shell")

objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Access\Security\VBAWarnings", 1, "REG_DWORD"