运行时错误'429':ActiveX组件无法创建对象

时间:2013-04-20 14:08:40

标签: windows vba excel-vba com vb6

我使用Excel工作VBA,Windows OS(32位)和Office 2007(办公室32位)工作正常当我开始使用Windows 8(64位)和Office 2010(64位)时,我无法因为excel Office 2010附带了VBA7,所以运行应用程序,因为我添加了以下代码行。

#If VBA7 Then 
Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr) 
#Else 
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 
#End If 
#If VBA7 Then 
Declare PtrSafe Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As LongPtr, ByVal dwShareMode As LongPtr, ByVal lpSecurityAttributes As Any, ByVal dwCreationDisposition As LongPtr, ByVal dwFlagsAndAttributes As LongPtr, ByVal hTemplateFile As LongPtr) As Long 
Declare PtrSafe Function WriteFile Lib "kernel32.dll" (ByVal hFile As LongPtr, ByRef lpBuffer As Any, ByVal nNumberOfBytesToWrite As LongPtr, ByRef lpNumberOfBytesWritten As LongPtr, ByRef lpOverlapped As LongPtr) As Long 
Declare PtrSafe Function ReadFile Lib "kernel32" (ByVal hFile As LongPtr, ByRef lpBuffer As Any, ByVal nNumberOfBytesToRead As LongPtr, ByRef lpNumberOfBytesRead As LongPtr, ByRef lpOverlapped As Any) As Long 
Declare PtrSafe Function CloseHandle Lib "kernel32.dll" (ByVal hObject As LongPtr) As Long 
#Else 
Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Any, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long 
Declare Function WriteFile Lib "kernel32.dll" (ByVal hFile As Long, ByRef lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, ByRef lpNumberOfBytesWritten As Long, ByRef lpOverlapped As Long) As Long 
Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, ByRef lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, ByRef lpNumberOfBytesRead As Long, ByRef lpOverlapped As Any) As Long 
Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long 
#End If

它工作正常但是当我尝试访问应用程序(excel表)时,我正在

错误“运行时错误429 - ActiveX组件无法创建对象”

我的问题:我只发布64位Windows 8和64位Office 2010

  1. 在上述声明代码中有错误吗?

  2. 可以强制在64位操作系统上运行32位COM对象吗?

  3. 此处创建对象

    Dim objScript As New ScriptControl
    Dim objNavFunctions As New NavFunctions
    ....
    ....
    ....
    
    objScript.Language = "vbscript" ' **// here getting error
    

1 个答案:

答案 0 :(得分:2)

Microsoft建议安装32位版本的Office,即使您可能有64位版本的Windows。 64位版本的功能较少,包括ActiveX控件和VBA限制等。以下是微软对此问题的引用。

  

“32位版本的Office中有什么但不包括在内   64位版本的Office?       ActiveX控件库,ComCtl此库包含用于构建解决方案的ActiveX控件。它最常用于   以下Microsoft Office程序:Access,Excel和Word。       SharePoint列表控件使用64位版本的Office的用户无法使用SharePoint技术中的列表视图。“

More here on Microsoft's article.

相关问题