Cars & Vehicles Auto Parts & Maintenance & Repairs

How to Use "Dispose" and "Nothing" in VBA

    • 1). Open Microsoft Excel.

    • 2). Click "Tools," "Macro," and then "Visual Basic." This will open the VBA programming environment.

    • 3). Click "Insert," then "Module." You are now in a programming code module.

    • 4). Type or copy and paste the following sub procedures in the code module:

      Sub UsingDisposeAndNothingEx()

      Dim objOutlook As Object

      objOutlook = GetObject(, "Outlook.Application")

      If Err.Number <> 0 Then MessageBox.Show("Please open the Outlook")

      objOutlook = Nothing

      objOutlook.dispose()

      End Sub



Leave a reply