I am tasked with connecting to an Access DB from a Word 2010 Macro. I downloaded the Microsoft sample database and the sample verification code but that does not work either. I can open the Access database so it does not appear to be corrupted. Using the following VBA code it appears that I am able to find the database but not open it.
When I execute the following code I receive the Error 3343: Unrecognized database format 'C:\Temp\Northwind.accdb" on the line
Set dbNorthwind = OpenDatabase(Name:="C:\Temp\Northwind.accdb")
Since I am using Microsoft's sample Access DB and Sample code what am I doing wrong and how do I correct this issue.
Thanks,
Sub UsingDAOWithWord()
Dim docNew As Document
Dim dbNorthwind As DAO.Database
Dim rdShippers As Recordset
Dim intRecords As Integer
'Set docNew = Documents.Add
Set dbNorthwind = OpenDatabase(Name:="C:\Temp\Northwind.accdb")
Set rdShippers = dbNorthwind.OpenRecordset(Name:="Shippers")
For intRecords = 0 To rdShippers.RecordCount - 1
docNew.Content.InsertAfter Text:=rdShippers.Fields(1).Value
rdShippers.MoveNext
docNew.Content.InsertParagraphAfter
Next intRecords
rdShippers.Close
dbNorthwind.Close
End Sub