vba 运行时错误“429”:ActiveX 组件无法创建对象
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16121232/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Run time error '429': ActiveX component can't create object
提问by Vikash
I working on VBA with Excel, Which working fine with windows OS (32 bit) and office 2007(office 32 bit) When i started work on Windows 8 (64 bit) and office 2010 (64 bit) i was unable to run the application so for below line of code i added because of excel office 2010 is comes with VBA7.
我使用 Excel 处理 VBA,在 Windows 操作系统(32 位)和 office 2007(office 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
it worked fine But when i try to Access the Application(excel sheet) i am getting
它工作正常但是当我尝试访问应用程序(excel表)时,我得到了
Error "Runtime Error 429 - ActiveX Component Can't Create Object "
错误“运行时错误 429 - ActiveX 组件无法创建对象”
My Problem : I Have Issue only with 64 bit Windows 8 and 64 bit Office 2010
我的问题:我只有 64 位 Windows 8 和 64 位 Office 2010 有问题
did any mistake in above Declared Code ?
Can force to run 32 bit COM object on 64 bit OS and How ?
上面声明的代码有什么错误吗?
可以强制在 64 位操作系统上运行 32 位 COM 对象以及如何运行?
Here creating the object
在这里创建对象
Dim objScript As New ScriptControl
Dim objNavFunctions As New NavFunctions
....
....
....
objScript.Language = "vbscript" ' **// here getting error
回答by ExcelVbaIsFun
Microsoft recommends installing the 32 bit version of office even though you may have a 64 bit version of windows. 64 bit version has less features, including ActiveX control and VBA limitations etc. Here's a quote from Microsoft on the issue.
Microsoft 建议安装 32 位版本的 Office,即使您可能有 64 位版本的 Windows。64 位版本的功能较少,包括 ActiveX 控件和 VBA 限制等。这是 Microsoft 对这个问题的引用。
"What is in the 32-bit version of Office but is not included in the 64-bit version of Office? ActiveX controls library, ComCtl This library contains ActiveX controls that are used to build solutions. It is most commonly used in the following Microsoft Office programs: Access, Excel, and Word. SharePoint List control The list view in SharePoint Technology is not available to people using the 64-bit version of Office."
《Office 32 位版本中有哪些不包含在 64 位版本 Office 中?ActiveX 控件库,ComCtl 这个库包含用于构建解决方案的 ActiveX 控件。它最常用于以下 Microsoft Office 程序:Access、Excel 和 Word。SharePoint 列表控件 SharePoint 技术中的列表视图对使用 64 位版本 Office 的人不可用。”