I've created a template for my client using Word 2013 32-bit. One of their users works with Word 2013 64-bit, he doesn't want to change and wants the template to work on his machine.
The following is part of the code which works OK in the 32-bit version:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim iNoOfRecords As Integer
VarPathLocal = Options.DefaultFilePath(wdUserTemplatesPath)
FullPath = VarPathLocal + "\" + "Acme Office Details.xls"
' Open the database
cmdDefaultOffice.Enabled = False
>>>>>>Set db = OpenDatabase(FullPath, False, False, "Excel 8")<<<<<<<
' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT * FROM `MyOfficeRange`")
' Determine the number of retrieved records
With rs
.MoveLast
iNoOfRecords = .RecordCount
.MoveFirst
End With
' Set the number of Columns = number of Fields in recordset
cboOfficeLocation.ColumnCount = 1 'rs.Fields.Count
' Load the ListBox with the retrieved records
cboOfficeLocation.Column = rs.GetRows(iNoOfRecords)
' Cleanup
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
The References I have set in the VBE are:
- Visual Basic for Applications
- Microsoft Word 15.0 Object Library
- OLE Automation
- Microsoft Office 15.0 Object Library
- Microsoft Forms 2.0 Object Library
- Microsoft DAO 3.6 Object Library
When I run it in the 64-bit version of Word it trips up in the line indicated by >>> <<< above and gives me this error "ActiveX component can't create object"
I've Googled all over the place and tried some ideas I found but with no result so reverted to the original.
Can anyone show me, please, how I can rectify the problem? I'm sure it's very simple but I can't get the right combination.
Thanks
Roderick