알쓸전컴(알아두면 쓸모있는 전자 컴퓨터)

vba ScriptControl 429 error 본문

VBA

vba ScriptControl 429 error

백곳 2019. 1. 30. 17:52

vba ScriptControl 429 error


ocx 가 등록 되어 있고 참조도 모두 했지만 특정 PC환경에서 429 에러가 날때가 있습니다.


Set ScriptEngine = New ScriptControl


이렇게 했을때 429 에러가 난다면

아래 소스를 추가한 다음에



Function CreateObjectx86(sProgID)

    Static oWnd As Object
    Dim bRunning As Boolean

    #If Win64 Then
        bRunning = InStr(TypeName(oWnd), "HTMLWindow") > 0
        If IsEmpty(sProgID) Then
            If bRunning Then oWnd.Close
            Exit Function
        End If
        If Not bRunning Then
            Set oWnd = CreateWindow()
            oWnd.execScript "Function CreateObjectx86(sProgID): Set CreateObjectx86 = CreateObject(sProgID): End Function", "VBScript"
        End If
        Set CreateObjectx86 = oWnd.CreateObjectx86(sProgID)
    #Else
        If Not IsEmpty(sProgID) Then Set CreateObjectx86 = CreateObject(sProgID)
    #End If

End Function

Function CreateWindow()

    ' source http://forum.script-coding.com/viewtopic.php?pid=75356#p75356
    Dim sSignature, oShellWnd, oProc

    On Error Resume Next
    sSignature = Left(CreateObject("Scriptlet.TypeLib").GUID, 38)
    CreateObject("WScript.Shell").Run "%systemroot%\syswow64\mshta.exe about:""<head><script>moveTo(-32000,-32000);document.title='x86Host'</script><hta:application showintaskbar=no /><object id='shell' classid='clsid:8856F961-340A-11D0-A96B-00C04FD705A2'><param name=RegisterAsBrowser value=1></object><script>shell.putproperty('" & sSignature & "',document.parentWindow);</script></head>""", 0, False
    Do
        For Each oShellWnd In CreateObject("Shell.Application").Windows
            Set CreateWindow = oShellWnd.GetProperty(sSignature)
            If Err.Number = 0 Then Exit Function
            Err.Clear
        Next
    Loop

End Function




Set ScriptEngine = CreateObjectx86("ScriptControl")


이렇게 사용해 주시면 해결 되는 경우도 있습니다.

'VBA' 카테고리의 다른 글

VBA Json 파싱  (0) 2018.12.21
excel을 DB 처럼 사용 하기  (0) 2017.08.07
VBA MSSQL 접속  (0) 2017.08.04
VBA 폴더내 파일 이름 조건 검색  (0) 2017.08.04
[VBA]CVS SQL로 연결  (2) 2017.08.04
Comments