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
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,148
Office Version
365, 2019, 2016, 2010
Platform
Windows, 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
34,148
Office Version
365, 2019, 2016, 2010
Platform
Windows, 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
34,148
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
Glad to help. It's always easy when you know how. ;)
 

Forum statistics

Threads
1,077,797
Messages
5,336,385
Members
399,080
Latest member
vivian prideaux

Some videos you may like

This Week's Hot Topics

Top