Share via

GUID - Run-time error '70' permission denied

Anonymous
2017-07-17T03:07:30+00:00

We have installed security update KB3213624 and it is causing an issue with our Excel - VBA script:

Public Function GetNewGuid() As String

GetNewGuid = Mid$(CreateObject("Scriptlet.TypeLib").GUID, 2, 36)

End Function

getting error "Run-time error '70' permission denied"

Uninstalling the security update KB3213624  - no more issue.

https://support.microsoft.com/en-au/help/3191907/descriptionofthesecurityupdateforexcel2010july11,2017

Is this a bug or expected behaviour from this latest update?

How to fix the code if it is not the Microsoft bug? Any suggestions?

Thanks.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2017-07-25T23:14:41+00:00

Hello,

This issue is by design, as of the July security updates. This control is blocked as a security measure to help prevent malicious code from running in Office applications. We are working on getting a knowledgebase article out with the recommended method. Until that KB is ready, I'll post the content here:

Office VBA “error 70” issue since the July 2017 security updates

Applies To: Office 2016, Office, 2013, Office 2010, Office 2007

The issue documented in this article has been reported after installing the recent updates listed below:

Security update for Office 2013: July 11, 2017 Security update for Office 2016: July 11, 2017

Issue: “Run-time error ‘70’ permission denied” with VBA in Office applications when using CreateObject(“Scriptlet.TypeLib”).GUID to create a GUID.

Here are what users would see when they run into the issue

This issue is by design. This control is blocked as a security measure to help prevent malicious code from running in Office applications.


Workaround

The preferred method is to change the code to use Windows API CoCreateGuid (https://msdn.microsoft.com/en-us/library/windows/desktop/ms688568(v=vs.85).aspx) instead of “CreateObject(“Scriptlet.TypeLib”).Guid”

Example of CreateObject error '70':

Dim strGuid As String

StrGuid = Left$(CreateObject("Scriptlet.TypeLib").Guid, 38)

Note: Writing code that works on both 32-bit and 64-bit Office

Example of CoCreateGuid(…): Vba7 Win64 Office 64-bit

‘ No VT_GUID available so must declare type GUID

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 CreateGuidString()

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

CreateGuidString = strGuid

End If

End if

End Function

Alternate Workaround

This will allow you to use CreateObject(“Scriptlet.TypeLib”) however it will lessen the security protection added by the Office July 2017 security update.

You can set a registry key that will allow Scriptlet.TypeLib to instantiate inside of Office applications. When this registry key is set, Office will not block any use of this COM control.

  • Open Registry Editor.
  • Go to: Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\16.0\Common\COM Compatibility{06290BD5-48AA-11D2-8432-006008C3FBFC}
    • Note: you may need to search the registry to find the correct location under HKEY_LOCAL_MACHINE based on your installed Office version.
  • Add ActivationFilterOverride
  • Set DWORD: 1

Detailed Instructions:

  1. Click Start, click Run, type regedit in the Open box, and then click OK.
  2. Locate and then click the following key in the registry:

HKEY_LOCAL_MACHINE

  1. On the Edit menu, point to Find, and then enter the following in the Find What: text box:

COM Compatibility 2. Ensure Keys is selected, and Values and Data are deselected. Next select Match whole string only, click Find Next 3. Locate and then click the following key:

{06290BD5-48AA-11D2-8432-006008C3FBFC}

Note: if the key is not present you will need to add it. On the Edit menu, point to New, and then click Key. Type in {06290BD5-48AA-11D2-8432-006008C3FBFC} 4. On the Edit menu, point to New, and then click DWORD (32-bit) Value 5. Type ActivationFilterOverride for the name of the DWORD, and then press Enter. 6. Right-click ActivationFilterOverride, and then click Modify. 7. In the Value data box, type 1 to enable the registry entry, and then click OK. 8. Note to disable the ActivationFilterOverride setting, type 0 (zero), and then click OK. 9. Exit Registry Editor, and then restart any open Office application.

Was this answer helpful?

30+ people found this answer helpful.
0 comments No comments

11 additional answers

Sort by: Most helpful
  1. Anonymous
    2017-07-17T12:28:35+00:00

    I have found another way to generate GUID, but not sure .. is it going to be "unique" ID ??

    Declare Function CoCreateGuid Lib "ole32" (ByRef GUID As Byte) As Long

    Public Function GetNewGuid() As String

    Dim ID(0 To 15) As Byte

    Dim N As Long

    Dim GUID As String

    Dim Res As Long

    Res = CoCreateGuid(ID(0))

    For N = 0 To 15

    GUID = GUID & IIf(ID(N) < 16, "0", "") & Hex$(ID(N))

    If Len(GUID) = 8 Or Len(GUID) = 13 Or Len(GUID) = 18 Or Len(GUID) = 23 Then

    GUID = GUID & "-"

    End If

    Next N

    GetNewGuid = GUID

    End Function

    PLEASE NOTE THIS FUNCTION WORKS FOR 32 BIT OFFICE and NOT FOR 64 BIT!!!

    Was this answer helpful?

    10+ people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2017-07-19T14:15:28+00:00

    Auto update was on. Going to kill it.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2017-07-19T13:10:52+00:00

    I guess you have Auto update from Microsoft and the KB3213624 is installed back again.

    I am now using the other function to generate GUID  and waiting for reply from Microsoft or somebody who is expert in this area :-). My users cant wait so had to implement work around solution.

    Please note, this second function works only for Office 32 bit. PC's with 64 bit Excel are having issue with ... CoCreateGuid Lib "ole32" ...

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2017-07-19T12:55:37+00:00

    Solved this problem yesterday by uninstalling KB3213624. Everything worked as advertised after that. However, today the same problem and KB3213624is no longer there. What now??

    Was this answer helpful?

    0 comments No comments