Integrating Dropbox access in Excel Macros

Introduction

If you’re managing data stored in Dropbox and want to automate its retrieval inside Excel, integrating ODBC with Excel VBA macros offers a powerful solution. This approach enables you to connect directly to your Dropbox content, extract metadata (such as file names, sizes, and modification dates), and display it in your spreadsheet, with just one click.

In this tutorial, you’ll learn how to connect to Dropbox using the ZappySys ODBC API Driver and automate metadata retrieval using Excel macros. This setup is ideal for building dynamic reports, dashboards, or audit tools that stay synchronized with your Dropbox files.

Prerequisites

  • Download and install the ZappySys ODBC PowerPack
  • A Dropbox account containing files
  • Microsoft Excel (Windows version with macro support)
  • Basic familiarity with the VBA editor in Excel

Step-by-step guide

Step 1: Create or select an app in the Dropbox developers portal

  1. Log in to your Dropbox account.

  2. Go to the Dropbox App Console and click Create app.

  3. Select Scoped access.

  4. Choose Full Dropbox (to access all files) or App folder (for limited access).

  5. Enter a name for your app and click Create app.

  6. Under Permission type, click Scoped App.

  7. Select required Individual Scopes, such as:

    account_info.read files.metadata.read files.content.read
    

    If managing team files, also add necessary Team Scopes.

  8. Navigate to the Settings tab and copy the App key and App secret to a safe place.

Step 2: Create a new ODBC data source (DSN)

  1. Open the ODBC Data Source Administrator by searching “ODBC” in the Windows Start menu.

  2. In the System DSN or User DSN tab, click Add.

  3. Choose ZappySys API Driver from the list, then select Dropbox from the connector list and click Continue.

Step 3: Configure the Dropbox connector

  1. Fill in the Client ID, Client Secret, and required scopes separated by spaces. Example:

    account_info.read files.metadata.read files.content.read
    
  2. Click Generate Token and complete the OAuth flow in your browser.

  3. After authentication, go to the Preview Tab, select the list_folder or equivalent endpoint, and click Preview.

  4. Click OK to save the DSN configuration.

Step 4: Write the Excel VBA macro

  1. Open Excel and go to the Developer tab. Click Visual Basic or press Alt + F11.

  2. In the VBA editor, go to Insert and then Module.

  3. Paste the following macro:

Sub ImportDataFromODBC_Dropbox()

    Dim connection As Object
    Dim recordset As Object
    Dim connectionString As String
    Dim sqlQuery As String
    Dim col As Integer
    Dim currentRow As Long

    Set connection = CreateObject("ADODB.Connection")
    Set recordset = CreateObject("ADODB.Recordset")

    connectionString = "DSN=API Driver - Dropbox" ' Replace with your actual DSN name
    sqlQuery = "SELECT Id, Name, Type, PathLower, PathDisplay, Revision, Size, IsDownloadable FROM list_folder"

    connection.Open connectionString
    connection.CommandTimeout = 900

    recordset.Open sqlQuery, connection, 0, 1

    If recordset.EOF Then
        MsgBox "No records found.", vbExclamation
    Else
        With ThisWorkbook.Sheets("Sheet1")
            .Cells.ClearContents

            For col = 0 To recordset.Fields.Count - 1
                .Cells(1, col + 1).Value = recordset.Fields(col).Name
            Next col

            currentRow = 2
            Do Until recordset.EOF
                For col = 0 To recordset.Fields.Count - 1
                    .Cells(currentRow, col + 1).Value = recordset.Fields(col).Value
                Next col
                currentRow = currentRow + 1
                recordset.MoveNext
            Loop

            .Columns.AutoFit
        End With

        MsgBox "Data was successfully imported from Dropbox.", vbInformation
    End If

    recordset.Close: Set recordset = Nothing
    connection.Close: Set connection = Nothing

End Sub

Step 5: Run the macro

  1. Close the VBA editor.
  2. Press Alt + F8, select ImportDataFromODBC_Dropbox, and click Run.
  3. Your Excel sheet will populate with metadata from Dropbox.
  4. Optionally, add a button in Excel and assign the macro for easier access.

Benefits of this integration

  • Real-time access to Dropbox file information from Excel
  • No manual downloads — data is fetched automatically via ODBC
  • Flexible queries — use SQL to filter or sort data
  • Repeatable automation — rerun the macro anytime

Troubleshooting tips

  • No data returned? Check your Dropbox app scopes and verify the query.
  • Token expired? Regenerate the token from the DSN configuration window.
  • Macro not executing? Enable macros in Excel via Trust Center Settings.

Conclusion

By combining Excel VBA macros with ODBC integration, you can seamlessly pull metadata from Dropbox and automate reports, logs, or dashboards. This approach saves time, eliminates manual file tracking, and gives you full control over how your data is presented in Excel.

With the ZappySys API Driver, your Dropbox content is just one macro away.

Related resources

Contact us

If you encounter any issues or have specific questions, reach out to our support team via live chat or support ticket using our email support@zappysys.com.