Click here to Skip to main content
15,885,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
VB
#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 i am getting Error "Runtime Error 429 - ActiveX Component Can't Create Object "

My Problem :
1. did any mistake in above Declared Code ?
2. can force to run 32 bit COM object on 64 bit OS and How ?
Posted
Updated 22-May-13 11:17am
v4

1 solution

I don't know the exact answer, but i would suggest you to tefer these:
Compiler Constants[^]
Compatibility Between the 32-bit and 64-bit Versions of Office 2010[^]
64-Bit Visual Basic for Applications Overview[^]

Debug your code and check where the program hangs-up (showing error).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900