时 间:2018-07-08 01:18:18
作 者:摘 要:过去 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/VBA 互联 交互技术,可以参考
Access软件 QQ交流群(群 :39785885)
Access源码 店
相关资源:GLONASS卫星位置计算与程序实现_葛奎_glonass_卫星位置__matlab…
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!