Version of Word is
Microsoft® Word für Microsoft 365 MSO (Version 2608 Build 16.0.20326.20072) 64 Bit
see the coding of the error:
Option Explicit
#If VBA7 And Win64 Then
Private Declare PtrSafe Function SetEnv Lib "kernel64" _ <====== I don't know why
Alias "SetEnvironmentVariableA" (ByVal chName As String, _
ByVal chValue As String) _
As Long
#Else
Private Declare Function SetEnv Lib "kernel32" _
**Alias "SetEnvironmentVariableA" (ByVal chName As String, _**
**ByVal chValue As String) _**
**As Long**
#End If
Public Sub SetPath()
Dim chPath$
Dim chWWIPath$
Dim ret
' read PATH variable
chPath$ = Environ("PATH")
' get DLL path from registry
' WA051201: use different registry setting
chWWIPath$ = System.PrivateProfileString("", "HKEY_CLASSES_ROOT\WWIDOCUMENT\InstallDir", "")
' chWWIPath$ = WordBasic.[GetPrivateProfileString$] _
' ("HKEY_CLASSES_ROOT\WWIDOCUMENT\InstallDir", "", "")
' if registry entry is not there use path of wwi.dot (but without historic subdirectory of central installation)
If chWWIPath$ = "" Then
chWWIPath$ = ActiveDocument.AttachedTemplate.path
If Right(chWWIPath$, 5) = "Wwi97" Then
chWWIPath = Left(chWWIPath$, Len(chWWIPath$) - 6)
End If
End If
' append DLL path if not already there
If chWWIPath$ <> "" _
And InStr(chPath$, chWWIPath$ + ";") = 0 _
And Right(chPath$, Len(chWWIPath$)) <> chWWIPath$ Then
chPath$ = chPath$ + ";" + chWWIPath$
' set PATH variable
ret = SetEnv("PATH", chPath$) **<===== Abbruch**
End If
End Sub