创建 GUID CreateObject("Scriptlet.TypeLib") 拒绝的权限
时 间:2018-07-08 01:18:18
作 者:何保辛 ID:22003 城市:深圳
摘 要:过去 CreateObject("Scriptlet.TypeLib") 产生 GUID 的方法,因为安全理由,2017年7月的安全更新里,已经被屏蔽,还是要用微软建议的新方法。
正 文:
当您运行 Visual Basic for Applications 调用 CreateObject("Scriptlet.TypeLib") (VBA) 代码。GUID函数来创建 GUID (Word、Excel 等),则 Microsoft Office 应用程序中您会收到以下错误消息:
Run-time error '70':
Permission denied
此问题是由于。在 7 月 2017年安全更新、 CreateObject("Scriptlet.TypeLib")。GUID 被阻止的 Office VBA 中的恶意代码的安全防范。
新的方法是:
Private Type GUID_TYPE Data1 As Long Data2 As Integer Data3 As Integer Data4(7) As Byte End Type Private Declare PtrSafe Function CoCreateGuid Lib "ole32.dll" (guid As GUID_TYPE) As LongPtr Private Declare PtrSafe Function StringFromGUID2 Lib "ole32.dll" (guid As GUID_TYPE, ByVal lpStrGuid As LongPtr, ByVal cbMax As Long) As LongPtr Function newGUID() Dim guid As GUID_TYPE Dim strGuid As String Dim retValue As LongPtr Const guidLength As Long = 39 'registry GUID format with null terminator {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} retValue = CoCreateGuid(guid) If retValue = 0 Then strGuid = String$(guidLength, vbNullChar) retValue = StringFromGUID2(guid, StrPtr(strGuid), guidLength) If retValue = guidLength Then ' valid GUID as a string newGUID = strGuid End If End If End Function
![]() |
开发者你们好,这是 地球信息思维开发者 dbaseIIIer (QQ325613888) |
Access软件网QQ交流群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 【Access高效办公】用复选...(06.24)
- 根据变化的日期来自动编号的示例...(06.20)
- 【Access高效办公】按日期...(06.12)
- 合并列数据到一个文本框的示例;...(05.06)
- 通过命令按钮让Access列表...(04.24)
- 统计当月之前(不含当月)的记录...(03.11)
- 【Access Inputbo...(03.03)
- 按回车键后光标移动到下一条记录...(02.12)
- 【Access Dsum示例】...(02.07)

学习心得
最新文章
- 【Access高效办公】用复选框控...(06.24)
- 根据变化的日期来自动编号的示例;根...(06.20)
- Access快速开发平台--Acc...(06.16)
- 【Access高效办公】按日期区间...(06.12)
- Access快速开发平台--生成复...(06.07)
- 仓库管理实战课程(25)-导航菜单...(06.06)
- 仓库管理实战课程(24)-库存月结...(06.05)
- 分享一个简单的X氏家谱小示例(06.04)
- 仓库管理实战课程(23)-先入先出(06.02)
- 仓库管理实战课程(22)-代理商库...(05.30)