Troubleshooting
Why Excel historian add-ins do not load in PowerShell automation
Short answer
Excel deliberately leaves worksheet add-ins unloaded when a script creates the application object, so historian functions return #NAME? even though the Reporter COM add-in loaded. Set the historian add-in's Installed property to $FALSE and back to $true on the Excel.Application object before opening the workbook, and a fresh scheduled session evaluates the same cells correctly.
On this page
- Why do historian formulas return #NAME? only when PowerShell opens the workbook?
- Why does Excel load the COM add-in but not the historian add-in?
- How do you load the Excel add-in from the PowerShell script?
- What order should the whole script run in?
- Why does the script work when Excel is already open?
- Does the Task Scheduler account change the fix?
- What if the add-in is missing from Excel Options?
- Questions asked
Excel does not enable worksheet add-ins when an application instance is created programmatically, which is why historian functions evaluate to #NAME? in a workbook your PowerShell script opens and return values in the same file you open yourself. The DeltaV Reporter COM add-in still loads at startup, so its presence proves nothing about the worksheet functions. The fix is two lines: set the add-in's Installed property to $FALSE and then to $true on the Excel.Application object before the first Workbooks.Open call. What follows gives the exact placement, the complete script order, why a leftover Excel session masks the fault, and what to check when the add-in is missing from Excel Options after a version move.
Why do historian formulas return #NAME? only when PowerShell opens the workbook? #
Because the worksheet add-in that registers those functions never loads in the scripted session — #NAME? is Excel's response to a name it cannot resolve, and an unloaded add-in function is exactly that. It is not a historian fault: a recognized function returning a connection, permission or data-quality error is a different failure, with the provider loaded.
The decisive comparison is one workbook, two launches. Opened manually, the historian cells evaluate; opened through a fresh Excel.Application with no Excel already running, the same cells show #NAME?. That isolates session initialization, not tags, timestamps or the workbook itself.
| What you observe | What it means | Next move |
|---|---|---|
| Formulas evaluate when the workbook opens manually | The workbook and its functions are sound in an interactive session | Compare add-in state in the scripted instance |
| #NAME? only after a fresh script launch | The function names are unresolved in that session | Activate the worksheet add-in explicitly |
| The script works while a blank workbook stays open | An initialized session is loading the add-in for you | Make the script self-sufficient, then retest |
| Functions resolve but values still fail | Registration is no longer the fault | Check historian access, query inputs and the execution account |
Slow refresh once tags accumulate is a separate fault with its own causes — see historian reads slow in Excel after adding tags.
Why does Excel load the COM add-in but not the historian add-in? #
Because Excel treats the two categories differently by design: COM add-ins load during application startup in every session, while Excel add-ins — worksheet add-ins like ContinuousHistorianWF — are not enabled when the application is started through automation. This is documented startup behavior for programmatic instances, not a broken installation and not a bug in your script.
Excel Options manages the two collections separately, under Manage: COM Add-ins and Manage: Excel Add-ins, and loading one says nothing about the other:
| DeltaV Reporter (COM add-in) | ContinuousHistorianWF (Excel add-in) | |
|---|---|---|
| Loads when Excel starts interactively | Yes | Yes |
| Loads when a script creates Excel.Application | Yes, at startup | No, not enabled in programmatic sessions |
| Registers the historian worksheet functions | No | Yes |
| Managed in Excel Options under | Manage: COM Add-ins | Manage: Excel Add-ins |
| Activation from a script | Not needed | Installed toggle |
So a loaded Reporter entry can coexist with a workbook full of #NAME? cells. Checking the COM add-in's state tells you nothing about the worksheet functions; the activation has to target the Excel add-in itself.
How do you load the Excel add-in from the PowerShell script? #
With two lines that flip the add-in's Installed property from $FALSE to $true on the Excel.Application object, placed after the object is created and before the workbook opens:
$xl = New-Object -ComObject "Excel.Application"
$xl.AddIns.Item("DeltaV Continuous Historian Excel Add-In").Installed = $FALSE
$xl.AddIns.Item("DeltaV Continuous Historian Excel Add-In").Installed = $true
$wb = $xl.Workbooks.Open($reportPath)
Three details decide whether these lines work:
- The string inside
AddIns.Item(...)is the registered name of the entry that provides ContinuousHistorianWF, exactly as Excel Options lists it under Manage: Excel Add-ins — here that entry is "DeltaV Continuous Historian Excel Add-In". It is not a variable to adapt by guesswork. - The
$FALSEpass comes first: clearing the installed state and setting it back to$trueruns the load sequence that registers the functions in this session. - The test that proves activation: read the property back before opening the workbook —
$xl.AddIns.Item("DeltaV Continuous Historian Excel Add-In").Installedreturns True — and the cells that held #NAME? evaluate once the workbook opens and recalculates.
$xl, $reportPath and $wb are script variables: the COM application object, a string holding the report's UNC path, and the workbook object.
What order should the whole script run in? #
Create the application, suppress dialogs, activate the add-in, then open, save, close, quit and release — with one ordering rule absolute: the activation must precede the first Workbooks.Open call.
# $xl: Excel.Application COM object
$xl = New-Object -ComObject "Excel.Application"
$xl.DisplayAlerts = $FALSE
# Activate the worksheet add-in before any workbook opens
$xl.AddIns.Item("DeltaV Continuous Historian Excel Add-In").Installed = $FALSE
$xl.AddIns.Item("DeltaV Continuous Historian Excel Add-In").Installed = $true
# $reportPath: string, UNC path to the report workbook
$reportPath = "\\fileserver\Reports\CondLoadout.xlsm"
$wb = $xl.Workbooks.Open($reportPath)
$wb.Save()
$wb.Close()
$xl.Quit()
# Release so no EXCEL.EXE process outlives the run
while ([System.Runtime.Interopservices.Marshal]::ReleaseComObject($wb)) {}
while ([System.Runtime.Interopservices.Marshal]::ReleaseComObject($xl)) {}
- Create the
Excel.Applicationobject — this session is the one that must own the add-in. - Set
DisplayAlertsto$FALSEso no dialog can stall an unattended run. - Toggle the add-in
Installed$FALSEthen$true, before any formula can calculate. - Open, save and close the workbook.
- Quit the application and release both COM objects, so no orphaned
EXCEL.EXEkeeps the next test from being a true fresh session.
Why does the script work when Excel is already open? #
Because that already-running interactive session loaded the worksheet add-in, so the scripted run lands in an environment where the functions are already registered — a dependency you should remove, not keep. Leaving a blank workbook open makes the result depend on desktop state, an active logon and a process nobody owns; all three fail after a reboot. With the toggle in the script, it builds its own prerequisite and the leftover session becomes irrelevant.
Prove the fault and the fix with four runs:
- Open the report manually and confirm the historian cells return values.
- Close the report and every Excel instance, and check Task Manager for an
EXCEL.EXEleft behind by an earlier automation run before calling the next test a fresh-session test. - Run the script without the toggle and record the #NAME? cells.
- Add the two activation lines, close Excel fully again, rerun, and confirm the same cells evaluate and the saved workbook holds values.
Does the Task Scheduler account change the fix? #
The two lines do not change, but their precondition does: the add-in must be registered for the account the task runs under, and your interactive test proves nothing about that account. Excel add-in registration and Excel Options are read per user, so a task running as a service or another logon can face an Excel profile that has never seen the add-in.
- Read the account configured in the Windows Task Scheduler task and compare it with the logon used for the successful manual test.
- Under the task account, open and save the workbook's UNC path — that proves share permission, not historian authorization.
- Under the task account, confirm the entry appears in Excel Options under Manage: Excel Add-ins with the exact name the script uses.
- Run one known historian query under that account before attributing any remaining failure to the workbook.
The documented configuration is 32-bit Excel; a task moved to a machine with a different Office architecture needs the add-in installed for that architecture, so confirm the entry exists there before scripting. Desktop Excel automation in a noninteractive session can also stall on dialogs and profile prompts an interactive run never shows: observe one controlled run under the task's real context before trusting the schedule.
What if the add-in is missing from Excel Options? #
Then no script line can help: AddIns.Item activates registered entries only, so the fix is to reinstall or repair the historian add-in on that machine until the entry appears under Manage: Excel Add-ins. Check the Disabled Items window on the Excel Options Add-ins screen first — an add-in Excel disabled after a crash can be re-enabled there. If the entry is simply absent, which happens after version moves such as a DV14 workbook opened on a DV15 system, run the vendor's installer for the Excel add-in component under the account that runs the task; one reported migration notes runtime values only resolved after an exceladdinruntime component from the installation folder was added, so follow that version's install documentation for the required components.
Once the entry exists and the functions resolve, historical queries that still fail on the new system are a historian-access fault, not a loading fault: troubleshoot query inputs, time ranges and account permissions there, and leave the script alone.
Questions asked
Does setting DisplayAlerts to $FALSE affect add-in loading?
No. DisplayAlerts only suppresses Excel's dialogs during the run, which keeps an unattended task from stalling on a prompt. Loading is controlled separately by each add-in's Installed state, so the activation lines are required even with alerts suppressed. Keep DisplayAlerts at $FALSE for scheduled runs, but expect it to silence dialogs, not to load components.
Will the same two lines work for other worksheet add-ins?
Yes, for any add-in listed in Excel Options with Manage set to Excel Add-ins. Replace the string with that add-in's registered name exactly as Excel shows it, keep the $FALSE-to-$true sequence, and keep the lines ahead of the first Workbooks.Open call. COM add-ins load at startup on their own, and automation add-ins follow their own registration rules.
Does this apply to 64-bit Excel or only to the 32-bit installation?
The documented case is 32-bit Excel with the DeltaV Reporter installation. The Installed property belongs to the Excel object model itself, so the same two lines apply regardless of bitness. What must match the architecture is the add-in installation: confirm the entry appears under Manage: Excel Add-ins in that exact Excel installation before scripting the toggle.
What if cells still show #NAME? after adding the activation lines?
Check three things in order: the string inside AddIns.Item must match the registered name character for character; the account running the script must have the add-in registered in its own Excel Options; and the workbook's functions must actually come from that add-in. If the entry is absent from Excel Options entirely, reinstall the add-in before changing another line of script.