Skip to main content
Skip table of contents

Migration guide: Velixo Classic VBA interop macros to Velixo NX

Overview

Using the latest version of Velixo Tools, you can automate Velixo NX operations using VBA, just like Velixo Classic. We expect this to be a significant enabler for existing partners, service providers, or VBA power users planning a migration to Velixo NX from Velixo Classic.

Today, can keep your VBA scripts operational while taking advantage of Velixo NX’s exclusive functions and features.

Follow the steps below to enable automating Velixo NX via VBA. Ensure that you adapt your existing scripts according to the guide to ensure they continue to work as intended.

For the Velixo NX installation guide, refer to our dedicated page.

Install Velixo Tools (version 7.1.715 or newer)

Follow the Velixo Tools installation guide.

Add Velixo Tools as a reference in the VB Editor

To enable support for Velixo’s VBA commands in your workbook:

  1. Open the workbook in Excel.

  2. Open the Visual Basic Editor – Alt + F11.

  3. Go to ToolsReferences…

    image-20250826-094500.png
  4. On the list of available references, find Velixo_NX_Tools, check the box.

  5. Make sure the box next to Velixo_Reports, if it exists, is unchecked.

  6. Click OK.

    image-20250826-094822.png

Adapt references to use the Velixo_NX_Tools library

Since your Velixo Classic-compatible scripts created the VelixoObj object using the Velixo_Reports COM library, which you replaced with Velixo_NX_Tools in the previous step, all type references and ProgID strings in your scripts need to match this change:

  • Change instances of class references from Velixo_Reports.VBA to Velixo_NX_Tools.VBA

  • Change referenced ProgID strings from "Velixo.Reports.Vba" to ("Velixo.NX.Tools.Vba")

Example

Original script used with Velixo Classic:

CODE
Sub CopyWorkbookWithoutFormulas()

  Dim velixoObj As Velixo_Reports.VBA
  Set velixoObj = CreateObject("Velixo.Reports.Vba")

  Application.DisplayAlerts = False

  velixoObj.CopyWorkbookWithoutFormulas "C:\The\Desired\Path\FileName.xlsx"

  Application.DisplayAlerts = True

  MsgBox "Workbook copied without formulas"
  
End Sub

Equivalent script with references updated to leverage Velixo NX and Velixo Tools:

CODE
Sub CopyWorkbookWithoutFormulas()

  Dim velixoObj As Velixo_NX_Tools.VBA
  Set velixoObj = CreateObject("Velixo.NX.Tools.Vba")

  Application.DisplayAlerts = False

  velixoObj.CopyWorkbookWithoutFormulas "C:\The\Desired\Path\FileName.xlsx"

  Application.DisplayAlerts = True

  MsgBox "Workbook copied without formulas"
  
End Sub

Voilá! While the steps above should be enough to keep your existing VBA scripts operational, with an important exception of writeback, which requires completing the recommended follow-up steps below.

Even if you don’t automate writeback via VBA, we strongly recommend following the optional migration steps below to convert your code to asynchronous callbacks. In some cases, using Classic-compatible synchronous functions may result in Excel becoming unresponsive. This happens because Velixo Tools and Velixo NX share Excel’s user interface processing thread.

Recommended: adapt your scripts to use asynchronous callbacks

To prepare the VBA scripts you used for automating Velixo Classic, replace the following Velixo VBA commands with their asynchronous counterparts by adding the Async suffix to the command names:

Synchronous command

Asynchronous counterpart

AddToAutoHideUnhideRows

AddToAutoHideUnhideRowsAsync

AddToAutoHideUnhideColumns

AddToAutoHideUnhideColumnsAsync

CopyWorkbookWithoutFormulas

CopyWorkbookWithoutFormulasAsync

ForgetAutoHideRangesOnWorksheet

ForgetAutoHideRangesOnWorksheetAsync

HideZeroRows

HideZeroRowsAsync

HideZeroColumns

HideZeroColumnsAsync

ProcessAllAutoHideRanges

ProcessAllAutoHideRangesAsync

WritebackWorksheet

WritebackWorksheetAsync

WritebackCurrentWorksheet

WritebackCurrentWorksheetAsync

Refresh

RefreshAsync

RefreshFull

RefreshFullAsync

RunDistributionList

RunDistributionListAsync

UnhideAll

UnhideAllAsync

The ActiveFunctionsCount command does not interfere with Excel’s calculations and can be used safely despite being synchronous.

To keep the scripts' behavior unaltered after switching to asynchronous versions of commands, three more alterations are necessary to maintain the original execution order:

  1. Extract VBA statements that succeeded your (formerly) synchronous command to a separate VB module (InsertModule in VB Editor).

  2. Add an AddOperationCompleteCallback call that references the new, asynchronous method before the command itself.

  3. Add a RemoveOperationCompleteCallback call to the newly-added VB module to prevent multiple subscription and execution of callbacks.

Example

Original, Velixo Classic-compatible VBA script leveraging the synchronous CopyWorkbookWIthoutFormulas command:

CODE
Sub CopyWorkbookWithoutFormulas()

  Dim velixoObj As Velixo_Reports.VBA
  Set velixoObj = CreateObject("Velixo.Reports.Vba")

  Application.DisplayAlerts = False

  velixoObj.CopyWorkbookWithoutFormulas "C:\The\Desired\Path\FileName.xlsx"

  Application.DisplayAlerts = True

  MsgBox "Workbook copied without formulas"
  
End Sub

Adapted, Velixo NX-compatible VBA script leveraging the asynchronous CopyWorkbookWIthoutFormulasAsync command, preceded by an AddOperationCompleteCallback call referencing the command:

CODE
Public Sub CopyWorkbookWithoutFormulas()

    Dim velixoObj As Velixo_NX_Tools.VBA
    Set velixoObj = CreateObject("Velixo.NX.Tools.Vba")
    
    Dim noArgs() As Variant
    velixoObj.AddOperationCompleteCallback ActiveWorkbook, VbaCommandName_CopyWorkbookWithoutFormulas, "ShowStatusCopyWithoutFormulas", noArgs

    Application.DisplayAlerts = False

    velixoObj.CopyWorkbookWithoutFormulasAsync "C:\The\Desired\Path\FileName.xlsx"

    Application.DisplayAlerts = True

End Sub

Note that in the example below, when adding a callback via AddOperationCompleteCallback, the type of operation we’re “subscribing” to does not contain the Async suffix. This is expected. For instance: VbaCommandName_WritebackCurrentWorksheet

And a VB module (InsertModule in VB Editor) containing the callback along with unsubscription logic:

CODE
Sub ShowStatusCopyWithoutFormulas()

    MsgBox "Workbook copied without formulas"
  
    Dim velixoObj As Velixo_NX_Tools.VBA
    Set velixoObj = CreateObject("Velixo.NX.Tools.Vba")
    
    Dim noArgs() As Variant
    velixoObj.RemoveOperationCompleteCallback ActiveWorkbook, VbaCommandName_CopyWorkbookWithoutFormulas, "ShowStatusCopyWithoutFormulas", noArgs

End Sub
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.