一个自动降低VBA宏安全级别的函数
时 间:2008-06-08 22:57:02
作 者:weizw55 ID:2173 城市:青浦
摘 要:可以在系统运行时自动修改安全级别的函数.
正 文:
一个自动降低VBA宏安全级别的函数
一般ACCESS的默认的宏安全级别为中级,这时程序在运行时总有许多烦人的提示.而对于普通的ACCESS终端用户来说,他们不会解决这个问题.而我们开发人员为了程序的安全通常是将所有的菜单都禁用掉了.如果让用户自己来改的话呢,则需要写代码来调用系统的菜单.只是这个方法不能自动完成,还是需要终端用自己来选.
以下是一段可以在系统运行时自动修改安全级别的函数.
我先抛砖,请各位大虾一起来发表意见,看看有没有更好的解决之法.
Function vbabat1()
'在当前目录下检查是否有VBA.BAT的文件.如果没有,创建一个.并写入数据后运行.以降低VBA的安全级别.
If Dir(CurrentProject.Path & "\VBA.bat") = "" Then
Dim hFile As Long
Dim Str2 As String
Dim str3 As String
Dim Str4 As String
Dim str5 As String
Dim str6 As String
Dim str7 As String
Dim str8 As String
str8 = Chr(34)
Str4 = "level"
str7 = "echo off"
str3 = "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Access\Security"
str5 = "reg add " & str8 & str3 & str8 & " /v " & str8 & Str4 & str8 & " /t" & " REG_DWORD /d " & str8 & "00000001" & str8 & " /f"
str6 = "reg delete " & str8 & str3 & str8 & " /v " & str8 & Str4 & str8 & " /f"
Str2 = str7 & Chr(13) & str6 & Chr(13) & str5
hFile = FreeFile
Open (CurrentProject.Path & "\VBA.bat") For Random As hFile
Close hFile
Open (CurrentProject.Path & "\VBA.bat") For Append Access Write As hFile
Print #hFile, str7
Print #hFile, str6
Print #hFile, str5
Close hFile
Call Shell((CurrentProject.Path & "\VBA.bat"), 1)
Else
If DatePart("w", Date) = 2 Then
Call Shell((CurrentProject.Path & "\VBA.bat"), 1)
End If
End If
End Function
Access软件网QQ交流群 (群号:483923997) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 【Access小作品】简单的待...(04.30)
- 【Access窗体导出PDF】...(04.08)
- 【Access窗体导出PDF】...(04.07)
- Access两种方式实现即时更...(03.01)
- Access隐藏与显示lacc...(01.12)
- 【Access高效办公】将每个...(12.23)
- Access21点游戏源代码(12.13)
- 【Access窗体导出Exce...(11.15)
- 【Access开发】Acces...(11.14)
学习心得
最新文章
- Access快速开发平台企业版--...(05.09)
- 新版铁路工程管理系统V2.0(05.08)
- Access快速开发平台企业版--...(05.07)
- 【Access Call用法学习】...(05.06)
- access软件网站长张志简介 (05.05)
- 精美简单实用的系统面板(05.03)
- 【Access小作品】简单的待办任...(04.30)
- 从另一个ACCESS数据库批量导入...(04.29)
- Access日期格式的数据导出Ex...(04.28)
- ACCESS精华集锦资料.CHM(04.25)