Workbooks.OpenDatabase (Excel)
Returns a Workbook object representing a database.
OpenDatabase (Filename, CommandText, CommandType, BackgroundQuery, ImportDataAs)
Dim strFilename As String: strFilename =
Dim wbOpenDatabase As Workbook
Set wbOpenDatabase = Workbooks.OpenDatabase(Filename:=strFilename)
Arguments
The following argument is required
Filename (String) - The connection string that contains the location and file name of the database.
Optional arguments
The following arguments are optional
CommandText - The command text of the query
CommandType - The command type of the query. Specify one of the constants of the XlCmdType enumeration: xlCmdCube, xlCmdList, xlCmdSql, xlCmdTable, and xlCmdDefault
BackgroundQuery - This parameter is a variant data type but you can only pass a Boolean value. If you pass True, the query is performed in the background (asynchronously). The default value is False
ImportDataAs - This parameter uses one of the values of the XlImportDataAs enumeration. The two values of this enum are xlPivotTableReport and xlQueryTable. Pass one of these values to return the data as a PivotTable or QueryTable. The default value is xlQueryTable
CommandText - The command text of the query
CommandType - The command type of the query. Specify one of the constants of the XlCmdType enumeration: xlCmdCube, xlCmdList, xlCmdSql, xlCmdTable, and xlCmdDefault
BackgroundQuery - This parameter is a variant data type but you can only pass a Boolean value. If you pass True, the query is performed in the background (asynchronously). The default value is False
ImportDataAs - This parameter uses one of the values of the XlImportDataAs enumeration. The two values of this enum are xlPivotTableReport and xlQueryTable. Pass one of these values to return the data as a PivotTable or QueryTable. The default value is xlQueryTable