VBA/Excel/Access/Word/Application/GetObject
Opening a Database as the Current Database and Closing the Current Database
Sub open()
Dim myAccess As Access.Application
Dim myDatabase As Object
Set myAccess = GetObject(, "Access.Application")
myAccess.CloseCurrentDatabase
myAccess.OpenCurrentDatabase _
filepath:="C:\mydb.mdb", Exclusive:=True
Set myDatabase = myAccess.CurrentDb
End Sub
Returning an Object with the GetObject Function
Sub Return_a_Value_from_Excel()
Dim mySpreadsheet As Excel.Workbook
Dim strSalesTotal As String
Set mySpreadsheet = GetObject("your.xls")
strSalesTotal = mySpreadsheet.Application.Range("SalesTotal").Value
Set mySpreadsheet = Nothing
Selection.TypeText "Current sales total: $" & strSalesTotal & "."
Selection.TypeParagraph
End Sub