Skip to content

RefreshAll

This will refresh all Skylights in the current document via VBA Script.

The Script

You’ll add code in two places inside the VBA editor.

Step 1 Script — ThisDocument Module (Auto-Trigger)

This goes in the ThisDocument module. It fires automatically when the document opens.

Private Sub Document_Open()
    On Error GoTo ErrHandler

    ' Optional: small delay to ensure the CALUMO add-in is fully loaded
    Application.OnTime When:=Now + TimeValue("00:00:01"), Name:="RefreshAllSkylights"
    Exit Sub

ErrHandler:
    MsgBox "Auto-refresh failed to start: " & Err.Description, vbExclamation
End Sub

Step 2 Script — Standard Module (Worker)

Insert a new module via Insert → Module and paste this in:

Public Sub RefreshAllSkylights()
    Dim addin As Object
    Dim util  As Object

    On Error Resume Next
    Set addin = Application.COMAddIns("Calumo.WordClient")
    On Error GoTo 0

    If addin Is Nothing Then
        MsgBox "CALUMO Word Client add-in is not installed or not loaded.", _
               vbExclamation, "CALUMO Refresh"
        Exit Sub
    End If

    If Not addin.Connect Then
        addin.Connect = True   ' make sure it's connected
    End If

    Set util = addin.Object
    If util Is Nothing Then
        MsgBox "Unable to access CALUMO Word Client automation object.", _
               vbExclamation, "CALUMO Refresh"
        Exit Sub
    End If

    Application.ScreenUpdating = False
    util.RefreshAll
    Application.ScreenUpdating = True
End Sub

Setup Instructions

  1. Open the document you want to auto-refresh.
  2. Press Alt + F11 to open the VBA editor.
  3. In the Project Explorer (left panel), expand your document’s project (e.g., Project (YourDoc)).
  4. Double-click ThisDocument → paste the Step 1 script (from above).
  5. Right-click the project → Insert → Module → paste the Step 2 script (from above).
  6. Press Ctrl + S. When prompted, save the file as Word Macro-Enabled Document (.docm).

Required Word Settings (One-Time)

For the macro to actually run on open, macros must be allowed.

1. Macro Settings

File → Options → Trust Center → Trust Center Settings… → Macro Settings

  • Choose Enable all macros (only if you trust the source), or preferably
  • Choose Disable all macros except digitally signed macros and sign your project, or
  • Add the document’s folder as a Trusted Location (Trust Center → Trusted Locations) — recommended.

2. Confirm the CALUMO Add-in Is Enabled

File → Options → Add-ins → Manage: COM Add-ins → Go…

  • Confirm Calumo.WordClient is checked.
Back to top