64 bit issue

oozuberk

New Member
Joined
Nov 12, 2019
Messages
3
Hi I'm working in 32 bit Excel but I'm getting error in Excel which is 64 bit. How do I edit the codes in 64 bits.

Public db As DAO.Database
Public rs As DAO.Recordset
Public sql As String
Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,517
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Change the API declaration code to:

Rich (BB code):
#If VBA7 Then
Declare PtrSafe Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
#Else 
Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
#End  If
 

oozuberk

New Member
Joined
Nov 12, 2019
Messages
3
As you said Hello, the code has changed, I get an error in the code. Excel 2013

Set db = OpenDatabase(ActiveWorkbook.FullName, False, False, "Excel 8.0")
Set rs = db.OpenRecordset(sql)
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,517
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
What reference are you using for the DAO? If it's DAO 3.6, that will not work in 64 bit Office. You'll need to replace it with the 'Microsoft Office 15.0 Access database engine Objects' reference.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,517
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Glad to help. It's always easy when you know how. ;)
 

Watch MrExcel Video

Forum statistics

Threads
1,109,257
Messages
5,527,657
Members
409,780
Latest member
Sudheer121

This Week's Hot Topics

Top