How do you open a ".mdf" file like "Northwind.mdf" in Access thru Excel VBA?
Open a ".mdf" file in Access thru Excel VBA
-
-
-
Re: Open a ".mdf" file in Access thru Excel VBA
Hi Philosophaie
one way by Julitta Korol
Code
Display MoreSub AccessViaAutomation() Dim objAccess As Access.Application Dim strPath As String On Error Resume Next Set objAccess = GetObject(, "Access.Application.11") If objAccess Is Nothing Then Set objAccess = New Access.Application End If strPath = "C:\Program Files\Microsoft Office\" & "Office11\Samples\Northwind.mdb" With objAccess .OpenCurrentDatabase strPath If MsgBox("Do you want to make the Access " & vbCrLf & "Application visible?", vbYesNo, "Display Access") = vbYes Then .Visible = True MsgBox "Notice the Access Application icon " & "now appears on the Windows taskbar." End If .CloseCurrentDatabase .Quit End With Set objAccess = Nothing End Sub
-
Re: Open a ".mdf" file in Access thru Excel VBA
This does not work as written.
Access just flashes and does not become visible.
How do you keep it on the desktop and open Access to a table?
-
Re: Open a ".mdf" file in Access thru Excel VBA
true , just delete the close access bit
Code
Display MoreSub AccessViaAutomation() Dim objAccess As Access.Application Dim strPath As String On Error Resume Next Set objAccess = GetObject(, "Access.Application.11") If objAccess Is Nothing Then ' Get a reference to the Access Application object Set objAccess = New Access.Application End If strPath = "C:\Program Files\Microsoft Office\" _ & "Office11\Samples\Northwind.mdb" ' Open the Northwind database With objAccess .OpenCurrentDatabase strPath If MsgBox("Do you want to make the Access " & vbCrLf _ & "Application visible?", vbYesNo, _ "Display Access") = vbYes Then .Visible = True MsgBox "Notice the Access Application icon " _ & "now appears on the Windows taskbar." End If ' Close the database and quit Access .CloseCurrentDatabase .Quit End With Set objAccess = Nothing End Sub
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!