PDA

View Full Version : Run time error '429': ActiveX component can't create object



Devendra
04-20-2013, 05:16 AM
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.
#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

Error "Runtime Error 429 - ActiveX Component Can't Create Object "


My Problem : I Have Issue only with 64 bit Windows 8 and 64 bit Office 2010
1. did any mistake in above Declared Code ?
2. Can force to run 32 bit COM object on 64 bit OS and How ?

Here creating the COM Object

mancubus
04-22-2013, 08:55 AM
following link may get you started:

Compatibility Between the 32-bit and 64-bit Versions of Office 2010 (http://msdn.microsoft.com/en-us/library/office/ee691831(v=office.14).aspx)