PDA

View Full Version : Opening up an Access File



autoxguy
12-01-2012, 01:10 PM
So I am using Excel to open up an Access file within a program I am making for class. The Access file opens up just fine, however, when I close out of the file, I get error '424 object required' and says the error is with the oApp.Visible = True line. I just want to know what this means and what I need to do to make the error not come up, below is the code I have.

Sub OpenAccessFile()

'Open Access and make visible
Set oApp = GetObject("E:\Documents\Info 395\BYBDatabase.accdb")

oApp.Visible = True

App.OpenCurrentDatabase LPath

TrustedApplication = yes



End Sub

Teeroy
12-01-2012, 03:25 PM
In your example the object is the File, not the Application. I don't work with Access in VBA (so I might be off track) but I would try oApp.Parent.Visible = True.

Trebor76
12-01-2012, 05:55 PM
Hey autoxguy,

Here's two simple methods of opening any file type (Access in this case):


Option Explicit
Sub Macro1()

'Two methods to any file - Access in this case
'Written by Trebor76
'Visit my website www.excelguru.net.au (http://www.excelguru.net.au)

'Method 1
CreateObject("Shell.Application").ShellExecute "E:\Documents\Info 395\BYBDatabase.accdb"

'Method 2
ActiveWorkbook.FollowHyperlink "E:\Documents\Info 395\BYBDatabase.accdb", NewWindow:=True

End Sub

HTH

Robert