Skip to content

Power User Tips

Kỹ thuật nâng cao kết hợp DVDAddin + Excel + scripting cho người dùng pro.

1. Macro VBA gọi DVDAddin UDF

UDF DVDAddin có thể được gọi từ VBA macro:

vba
Sub TestDvdUDF()
    Dim result As String
    result = Application.Run("DvdNumToText", 1234567)
    Debug.Print result   ' "Một triệu hai trăm ba mươi tư..."

    Dim translated As String
    translated = Application.Run("DvdTranslateGoogle", "Hello", "en", "vi")
    Debug.Print translated   ' "Xin chào"
End Sub

→ Tự động hóa workflow trong VBA.

Lưu ý: UDF async (DvdAskGemini, DvdHttpGet) sẽ block VBA cho đến khi resolve. Set timeout dài.

2. Power Query + DVDAddin

Power Query không gọi UDF trực tiếp, nhưng có thể combine:

Pattern: PQ load data → UDF process → output

  1. Power Query load CSV / Database → sheet RawData.
  2. Sheet Processed có công thức =DvdRemoveDiacritics(RawData!A2) cho mỗi cell.
  3. Refresh PQ → RawData update → Processed tự recalc.

Pattern: Custom Function trong Power Query

PQ custom function gọi UDF qua Excel.CurrentWorkbook → access sheet name có result UDF.

Advanced — chỉ recommend cho user có experience PQ.

3. Conditional Format dùng UDF

CF rule: "Use a formula to determine which cells to format":

=DvdRegexMatch(A1, "\d{4}-\d{2}-\d{2}")

→ Tô màu cell có format date yyyy-MM-dd.

=DvdIsLicensed()    (sẽ implement 2.8+)

→ CF chỉ active khi license valid (hint không expose feature cho user expired).

4. Multi-monitor workflow

Excel hỗ trợ multi-monitor từ 2013+. Tận dụng với DVDAddin:

Setup

  • Monitor 1: Excel workbook chính.
  • Monitor 2: DVDAddin dialogs modeless (Translate, AI Assistant, Navigation Panel).

DVDAddin dialogs ban đầu show center của Excel main window. Drag sang monitor 2 → lưu vị trí cuối → lần sau mở vẫn ở đó.

Touch screen / tablet mode

Surface Pro / iPad with Excel mobile:

  • DVDAddin support touch — button có hit area đủ lớn.
  • Modal dialog có thể scroll touch.
  • Hạn chế trên Excel mobile: chỉ một số UDF, không có ribbon DVDAddin (chỉ trong desktop Excel).

5. Custom toolbar / QAT

Excel có Quick Access Toolbar (QAT) — pin lệnh dùng nhiều:

  1. Right-click button DVDAddin → "Add to Quick Access Toolbar".
  2. QAT button hiện trên thanh trên cùng (above ribbon hoặc below).
  3. Phím tắt: Alt + 1/2/3/... (theo thứ tự QAT).

Recommended QAT:

  • Bản quyền (check expiry).
  • Translate.
  • AI Assistant.
  • Đánh số.
  • Sheet List.

6. Excel-DNA shim debugging

Khi DVDAddin gặp lỗi không hiển thị message:

Bật verbose log

Environment variable:

powershell
[Environment]::SetEnvironmentVariable('EXCELDNA_DEBUG', '1', 'User')

Restart Excel → log chi tiết tại %TEMP%\DVDAddin-AddIn*.log.

Inspect load failures

Lệnh PowerShell:

powershell
Get-ChildItem "$env:TEMP" -Filter 'DVDAddin-AddIn*.log' |
    Sort-Object LastWriteTime -Descending |
    Select-Object -First 1 |
    Get-Content -Tail 100

→ Show 100 dòng cuối log mới nhất.

7. Reverse-engineer DVDAddin behavior

DVDAddin source code: github.com/dangdvd/DVDAddin.

Read source để hiểu behavior

Vd: muốn hiểu translate dialog hoạt động sao:

  1. Browse src/DVDAddin.UI/Dialogs/TranslateDialog.xaml.cs.
  2. Read comments + code logic.
  3. Verify hypothesis bằng cách trigger feature + observe.

Build custom version

Clone + modify:

bash
git clone https://github.com/dangdvd/DVDAddin.git
cd DVDAddin
# edit some code
dotnet build -c Release

Output: src/DVDAddin.ExcelAddin/bin/Release/net8.0-windows/DVDAddin-AddIn(64).xll.

Replace C:\DVDAddin\DVDAddin-AddIn64-packed.xll với version của bạn.

⚠️ Custom build sẽ KHÔNG được auto-update.

8. Excel-DNA RTD (Real-time Data)

UDF async của DVDAddin dùng Excel-DNA RTD internally. Power user có thể tự viết RTD client gọi server giống cách DVDAddin gọi:

Tài liệu Excel-DNA: excel-dna.net.

→ Advanced — chỉ for developer.

9. Excel JavaScript add-in (Office.js)

DVDAddin là Excel-DNA .xll desktop add-in. Excel Online / Mac có Office.js add-in khác hẳn.

DVDAddin KHÔNG support Excel Online / Mac. Tương lai 3.0 có thể implement Office.js version (chỉ subset features có thể port).

10. Multi-language workbook

Workbook chứa text song ngữ VI + EN:

  • Cell A có text VI: =DvdTranslateGoogle(A1, "vi", "en") → cell B có text EN.
  • Format: ="Vietnamese: " & A1 & " | English: " & B1.

→ Workbook đa ngôn ngữ cho khách quốc tế.

11. Excel + Python integration

Office 365 có Python in Excel (Microsoft Insider Channel — 2024+).

Combine với DVDAddin:

  • DVDAddin UDF cho text processing nhanh trong cell.
  • Python cell (=PY(...)) cho analytics phức tạp (pandas, numpy).

Synergy: data flow Excel → DVDAddin UDF → Python analytics → output back to Excel.

12. Scheduled task chạy Batch Print weekly

PowerShell script chạy Excel automation:

powershell
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $false
$wb = $excel.Workbooks.Open('D:\Project\Report.xlsx')

# Trigger DVDAddin Batch Print via macro
$excel.Run('btnBatchPrint_Click')

# Wait for completion
Start-Sleep -Seconds 60

$wb.Close($false)
$excel.Quit()

Schedule task:

  • Windows Task Scheduler → New Task.
  • Trigger: Weekly Monday 8AM.
  • Action: Run PowerShell script trên.

→ Excel auto generate báo cáo tuần Monday morning. Bạn vào văn phòng đã có sẵn PDF.

13. Auto-update workbook từ shared drive

Workbook tham chiếu external file qua mạng:

='\\server\share\BangGia.xlsx'!Sheet1.A1

→ Mỗi save server → workbook con tự update.

Combined với Connect Server:

  • Connect Server sync BangGia về local copy D:\Sync\BangGia.xlsx.
  • Workbook tham chiếu local copy thay vì network direct.
  • → Vẫn auto-update + KHÔNG phụ thuộc network khi mở.

14. Auto-archive PDFs theo ngày

Script PowerShell chạy mỗi tối:

powershell
$today = Get-Date -Format 'yyyy-MM-dd'
$src = 'D:\Output\BBNT'
$dst = "D:\Archive\BBNT\$today"

if (-not (Test-Path $dst)) { New-Item -ItemType Directory -Path $dst | Out-Null }
Move-Item -Path "$src\*.pdf" -Destination $dst

Schedule: daily 11PM.

→ Folder D:\Output\BBNT\ luôn clean. Archive tự lưu theo ngày.

15. AI-powered Excel formula generator

Cell:

=DvdAskGemini("Generate Excel formula cho: tính tổng cột B, chỉ các hàng có cột A = 'Hà Nội'. Trả về formula thôi, không giải thích.")

→ Gemini trả =SUMIF(A:A, "Hà Nội", B:B).

→ Power user query formula complex thay vì Google search.

16. Workflow recording cho training

Dùng Auto Click record workflow:

  1. Record toàn bộ workflow lập 1 báo cáo (10-20 phút).
  2. Save sequence BaoCao_Tuan.dvdac.
  3. Đào tạo intern: replay sequence → intern xem step-by-step.

→ Training material không cần screen recorder.

17. Cross-workbook UDF call

Workbook B muốn dùng UDF của workbook A đã có Add-in custom:

  • Add-in DVDAddin đã global (xll loaded toàn Excel) → mọi workbook gọi được.
  • Custom VBA xlam của bạn cần "Tools → References" → tick workbook A.

18. Backup license trước khi update Windows

Windows feature update (vd: 23H2 → 24H2) thường giữ user profile, NHƯNG có thể reset một số registry.

Trước khi update:

powershell
$src = "$env:LOCALAPPDATA\DVDAddin\license.dat"
$dst = "$env:USERPROFILE\Documents\license.dat.bak"
Copy-Item $src $dst -Force

Sau khi update — nếu license biến mất:

powershell
Copy-Item $dst $src -Force

19. Excel-DNA debugging breakpoint

Cho developer build custom DVDAddin từ source:

  1. Open project trong Visual Studio.
  2. Project properties → Debug → Start external program = C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE.
  3. Set breakpoint trong code.
  4. F5 → Excel khởi động → addin load → breakpoint hit khi user click button.

20. RPC for cross-language integration

DVDAddin có internal RPC để Python / Node.js script gọi UDF qua named pipe (in 2.9+ plan).

Hiện tại workaround:

  • Python script ghi data ra .csv.
  • Excel macro chạy bằng pywin32 mở file + run UDF macro.

Liên quan

Released under DVDAddin License.