MS Access VBA Error: Run time error '70' Permission Denied

后端 未结 3 1100
花落未央
花落未央 2020-11-28 12:15

I believe this issue is a result of a recent update to MS Office/Access or Windows 10. When I run this code:

Dim s As String
With CreateObject(\"Scriptlet.T         


        
3条回答
  •  萌比男神i
    2020-11-28 12:55

    In Access, we can suffice with this very short function to generate a GUID by leveraging Application.StringFromGUID to cast bytes to a GUID. It generates pretty verbose GUIDs, though, with the format {guid {00000000-0000-0000-0000-000000000000}}.

    Declare PtrSafe Sub CoCreateGuid Lib "ole32" (ByVal GUID As LongPtr)
    Public Function NewGUID() As String
        Dim b(15) As Byte
        CoCreateGUID VarPtr(b(0))
        NewGUID = Application.StringFromGUID(b)
    End Function
    

    You can strip away unwanted characters, for example by replacing the last line of this function with NewGUID = Mid(Application.StringFromGUID(b), 8, 36). Then, the format will be 00000000-0000-0000-0000-000000000000

提交回复
热议问题