Excel desktop POC: direct SQL via VBA, safe mode launcher
- GLAccountsExcelApi.bas: RefreshGLApi reads Setup!B6:B9 directly, calls PostgreSQL via ADODB without sheet.Evaluate or live UDF formulas - Connection string pointed to vps107.geneva.hosting / postgres - GL_Accounts_Client_Template.xlsx: fixed formula text cell refs (B6 not B7) - Ouvrir_Excel_SafeMode.bat: launches Excel /safe with template to bypass print spooler freeze (splwow64 deadlock on edit mode entry) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,17 @@ This POC covers only the PDF section **GL ACCOUNTS FUNCTIONS**.
|
||||
- `gl_accounts_sql_poc.sql`: PostgreSQL schema/view/functions.
|
||||
- `GLAccountsExcelApi.bas`: VBA module exposing Excel formulas.
|
||||
- `GL_Accounts_POC.xlsx`: sample workbook with formulas wired to the VBA UDFs.
|
||||
- `GL_Accounts_POC_client_safe.xlsm`: macro-enabled workbook copy configured
|
||||
with manual calculation and no forced recalculation on open.
|
||||
- `GL_Accounts_POC_client_formula_text.xlsx`: client-safe workbook template
|
||||
with formulas stored as text, no VBA project, and no active UDF formulas.
|
||||
- `GL_Accounts_Client_Template.xlsx`: recommended client delivery workbook
|
||||
with setup and functions sheets, formulas stored as text, no VBA project,
|
||||
and no active UDF formulas.
|
||||
- `CLIENT_DELIVERY_README.md`: recommended client packaging and setup flow.
|
||||
- `GL_Accounts_Functions_Documentation.md`: user-facing function reference.
|
||||
- `GL_Accounts_Functions_Documentation.pdf`: PDF export of the function
|
||||
reference.
|
||||
|
||||
## SQL Objects
|
||||
|
||||
@@ -20,6 +31,8 @@ The SQL creates:
|
||||
- `excel_api.get_account_abbr(company, account, currency, date)`
|
||||
- `excel_api.get_account_name(company, account, currency, date)`
|
||||
- `excel_api.get_account_contact(company, account, currency, date)`
|
||||
- `excel_api.get_account_contact_code(company, account, currency, date)`
|
||||
- `excel_api.get_account_contact_name(company, account, currency, date)`
|
||||
|
||||
## Excel Formulas
|
||||
|
||||
@@ -32,6 +45,8 @@ After importing the VBA module:
|
||||
=GetAccountAbbr("COMPANY01","400000","USD",DATE(2026,5,31))
|
||||
=GetAccountName("COMPANY01","400000","USD",DATE(2026,5,31))
|
||||
=GetAccountContact("COMPANY01","400000","USD",DATE(2026,5,31))
|
||||
=GetAccountContactCode("COMPANY01","400000","USD",DATE(2026,5,31))
|
||||
=GetAccountContactName("COMPANY01","400000","USD",DATE(2026,5,31))
|
||||
```
|
||||
|
||||
The sample workbook already contains these formulas in the `GL Accounts POC`
|
||||
@@ -46,11 +61,36 @@ sheet. Save it as `.xlsm` after importing the VBA module.
|
||||
currency id, `currency_currency.code`, `name`, `symbol`, or `numeric_code`.
|
||||
- `GetAccountAbbr` returns `account_account.code` because no separate GL
|
||||
abbreviation field exists in the current schema.
|
||||
- `GetAccountContact` returns a comma-separated list of parties found on
|
||||
posted GL lines for the account/currency/date.
|
||||
- `GetAccountContact` is kept for backward compatibility and returns the
|
||||
contact code when available, otherwise the contact name.
|
||||
- `GetAccountContactCode` returns contact codes when available, otherwise
|
||||
names.
|
||||
- `GetAccountContactName` returns contact names when available, otherwise
|
||||
codes.
|
||||
- `GetAccountBaseAmount` revalues the transaction amount at `value_date` using
|
||||
`currency_currency_rate`.
|
||||
|
||||
## Client-Safe Workbook Packaging
|
||||
|
||||
For external delivery, prefer `GL_Accounts_Client_Template.xlsx` as the stable
|
||||
starting point. It contains no VBA project and no active UDF formulas, so Excel
|
||||
cannot open an ODBC connection during workbook startup.
|
||||
|
||||
The previous `.xlsm` workbooks can block at `Opening ... 0%` because they
|
||||
combine an embedded VBA project with active `GetAccount...` formulas. Even
|
||||
with manual calculation, Microsoft 365 may inspect or recalculate these UDF
|
||||
cells while loading the workbook.
|
||||
|
||||
Recommended delivery workflow:
|
||||
|
||||
1. Send the `.xlsx` template with formulas stored as text.
|
||||
2. Send/import `GLAccountsExcelApi.bas` separately where macros are allowed.
|
||||
3. On the `Functions` sheet, run `InstallGLApiFormulas` instead of editing
|
||||
formula text manually. It prepares result cells without writing live
|
||||
worksheet formulas.
|
||||
4. Use `RefreshGLApi` to call the database and write plain result values
|
||||
instead of relying on edit-time, open-time, or paste-time recalculation.
|
||||
|
||||
## Session Notes - 2026-05-26
|
||||
|
||||
Validated manually with Excel Desktop in safe mode after Excel initially hung
|
||||
@@ -98,11 +138,13 @@ Next session:
|
||||
`ClearGLApiCache` / `CloseGLApiConnection`.
|
||||
- Consider moving ODBC connection settings to a hidden/settings worksheet
|
||||
instead of hardcoding `GL_API_CONNECTION_STRING`.
|
||||
- Review whether contact output should be party codes, names, or both.
|
||||
- Import the new VBA wrappers if a workbook needs distinct contact code/name
|
||||
formulas.
|
||||
|
||||
## Recommended Production Shape
|
||||
|
||||
For production, prefer a readonly DB user and an ODBC DSN. The VBA module is a
|
||||
For production, prefer a readonly DB user and a named ODBC System DSN, for
|
||||
example `DSN=TradonGLApi;Uid=tradon_readonly;Pwd=...;`. The VBA module is a
|
||||
minimal proof of concept; a production workbook should add:
|
||||
|
||||
- a settings sheet for connection parameters;
|
||||
|
||||
Reference in New Issue
Block a user