-2

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 object

Dim objScript As New ScriptControl
Dim objNavFunctions As New NavFunctions
....
....
....

objScript.Language = "vbscript" ' **// here getting error
Vikash
  • 27
  • 2
  • 2
  • 5
  • 6
    There was little sense in deleting [your original question](http://stackoverflow.com/q/16010260/11683) and reposting 90% of its contents. The answer will not change. The `Declare`s are still not relevant, and you still cannot use a 32-bit control from a 64-bit program. If [there is no 64-bit version of a control](http://stackoverflow.com/a/15549450/11683), there's nothing you can do. The bitness of the OS still does not matter, too. Only Office bitness matters. Install 32-bit Office on 64-bit Windows, and you will be fine. – GSerg Apr 20 '13 at 14:45
  • Thanks,I am new in VBA Programming. you mean i have to use 64 bit version of control for 64 bit office,could you give more hint to use 64 bit controls.i can not force user to use only 32 office. – Vikash Apr 20 '13 at 15:48
  • Then you cannot use the control that only exists as 32-bit. If you must support both 32-bit and 64-bit office, you must either only use controls that exist in both kinds, or do not use any controls at all. – GSerg Apr 20 '13 at 16:05
  • Actually you can use a 32-bit control from a 64-bit Office, check [this answer](https://stackoverflow.com/a/38134477/2165759). – omegastripes Jan 20 '18 at 20:13

1 Answers1

2

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.

"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."

More here on Microsoft's article.

Siddharth Rout
  • 147,039
  • 17
  • 206
  • 250
  • 11
    I have edited your post. You might want to read [this](http://stackoverflow.com/faq#signatures) and [this](http://stackoverflow.com/faq#promotion) – Siddharth Rout Apr 20 '13 at 16:12