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:
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
- Power Query load CSV / Database → sheet
RawData. - Sheet
Processedcó công thức=DvdRemoveDiacritics(RawData!A2)cho mỗi cell. - Refresh PQ →
RawDataupdate →Processedtự 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:
- Right-click button DVDAddin → "Add to Quick Access Toolbar".
- QAT button hiện trên thanh trên cùng (above ribbon hoặc below).
- 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:
[Environment]::SetEnvironmentVariable('EXCELDNA_DEBUG', '1', 'User')Restart Excel → log chi tiết tại %TEMP%\DVDAddin-AddIn*.log.
Inspect load failures
Lệnh 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:
- Browse
src/DVDAddin.UI/Dialogs/TranslateDialog.xaml.cs. - Read comments + code logic.
- Verify hypothesis bằng cách trigger feature + observe.
Build custom version
Clone + modify:
git clone https://github.com/dangdvd/DVDAddin.git
cd DVDAddin
# edit some code
dotnet build -c ReleaseOutput: 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:
$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:
$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 $dstSchedule: 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:
- Record toàn bộ workflow lập 1 báo cáo (10-20 phút).
- Save sequence
BaoCao_Tuan.dvdac. - Đà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:
$src = "$env:LOCALAPPDATA\DVDAddin\license.dat"
$dst = "$env:USERPROFILE\Documents\license.dat.bak"
Copy-Item $src $dst -ForceSau khi update — nếu license biến mất:
Copy-Item $dst $src -Force19. Excel-DNA debugging breakpoint
Cho developer build custom DVDAddin từ source:
- Open project trong Visual Studio.
- Project properties → Debug → Start external program =
C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE. - Set breakpoint trong code.
- 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
pywin32mở file + run UDF macro.
Liên quan
- Customization — registry config deep dive.
- Performance — tối ưu workbook.
- Auto Click — record/replay.
- GitHub — source code.