Skip to content

WIP: Replace ribbon KeyTip sequences with direct VBA calls - #59

Draft
sean-garwood wants to merge 1 commit into
sha5010:mainfrom
sean-garwood:fix/keystroke-57
Draft

WIP: Replace ribbon KeyTip sequences with direct VBA calls#59
sean-garwood wants to merge 1 commit into
sha5010:mainfrom
sean-garwood:fix/keystroke-57

Conversation

@sean-garwood

@sean-garwood sean-garwood commented Jul 25, 2026

Copy link
Copy Markdown

Summary

  • Replace KeyStroke(Alt_, ...) ribbon KeyTip sequences with direct VBA object-model calls or Application.CommandBars.ExecuteMso, so commands work regardless of ribbon customization
  • Eliminates Excel version-detection hacks in AlignLeft/AlignRight (no longer needed with direct property assignment)
  • Net reduction of ~26 lines across 8 files

Addresses #57 (and likely #58)

Changes by file

File Conversions
Font.bas Alignment (6 funcs) -> Selection.HorizontalAlignment/VerticalAlignment; font grow/shrink -> ExecuteMso; ChangeFormat -> ExecuteMso "NumberFormatsDialog"
Row.bas Insert rows -> EntireRow.Insert; autofit -> EntireRow.AutoFit; height dialog -> Application.Dialogs(xlDialogRowHeight)
Column.bas Insert/unhide/autofit/width -> direct object model and Application.Dialogs
Cell.bas Fill down/up/left/right -> Selection.FillDown etc.; indent/decimals -> ExecuteMso; wrap text -> direct toggle; merge/unmerge -> object model + ExecuteMso "MergeCenter"; comma style -> ExecuteMso; AutoSum family -> ExecuteMso
Filter.bas Toggle/clear/apply autofilter -> ShowAutoFilterDropDown, AutoFilterMode, ShowAllData, UsedRange.AutoFilter
Paste.bas Paste values -> PasteSpecial xlPasteValues; RTF/HTML -> ExecuteMso
Find_Replace.bas ShowReplaceWindow -> ExecuteMso "ReplaceDialog"
UsefulCmd.bas Print area, sort, remove duplicates -> ExecuteMso

Not converted (safe as-is)

  • ChangeFontName/ChangeFontSize (focus ribbon combo box; no ExecuteMso equivalent; genuinely interactive)
  • ShowMacroDialog (Alt+F8 standard shortcut, not ribbon-dependent)
  • ShowFilterDialog (Alt+Down standard shortcut, not ribbon-dependent)
  • All Ctrl+ combos (bold, italic, etc.) and Alt+Shift+Right/Left (group/ungroup)

Test plan

Status: untested - no Excel available on dev machine; will verify Monday with Excel.

Regression checks (default ribbon)

  • Font: increase font size (Alt, H, F, G)
  • Font: decrease font size (Alt, H, F, K)
  • Font: change font name (Alt, H, F, F - kept as KeyStroke)
  • Font: change font size (Alt, H, F, S - kept as KeyStroke)
  • Alignment: left (Alt, H, A, L)
  • Alignment: center (Alt, H, A, C)
  • Alignment: right (Alt, H, A, R)
  • Alignment: top (Alt, H, A, T)
  • Alignment: middle (Alt, H, A, M)
  • Alignment: bottom (Alt, H, A, B)
  • ChangeFormat opens Number Format dialog (Alt, H, N, Down, Down)
  • Row: insert (Alt, I, R)
  • Row: append (insert below; Alt, I, R)
  • Row: autofit height (Alt, H, O, A)
  • Row: set height dialog (Alt, H, O, H)
  • Column: insert (Alt, I, C)
  • Column: append (insert right; Alt, I, C)
  • Column: unhide (Alt, H, O, U, L)
  • Column: autofit width (Alt, H, O, I)
  • Column: set width dialog (Alt, H, O, W)
  • Cell: fill down / YankFromUpCell (Alt, H, F, I, D)
  • Cell: fill up / YankFromDownCell (Alt, H, F, I, U)
  • Cell: fill right / YankFromLeftCell (Alt, H, F, I, R)
  • Cell: fill left / YankFromRightCell (Alt, H, F, I, L)
  • Cell: increment indent (Alt, H, 6)
  • Cell: decrement indent (Alt, H, 5)
  • Cell: increase decimal (Alt, H, 0)
  • Cell: decrease decimal (Alt, H, 9)
  • Cell: toggle wrap text (Alt, H, W)
  • Cell: merge cells (Alt, H, M, M)
  • Cell: unmerge cells (Alt, H, M, U)
  • Cell: apply comma style (Alt, H, K)
  • Cell: AutoSum (Alt, M, U, S)
  • Cell: AutoAverage (Alt, M, U, A)
  • Cell: AutoCount (Alt, M, U, C)
  • Cell: AutoMax (Alt, M, U, M)
  • Cell: AutoMin (Alt, M, U, I)
  • Filter: toggle autofilter, worksheet (Alt, A, T)
  • Filter: toggle autofilter, table (Alt, J, T, B)
  • Filter: clear all filters (Alt, A, C)
  • Filter: filter by active cell value (triggers ApplyAutoFilter; Alt, A, T)
  • Paste: paste values from cell copy (Alt, H, V, V)
  • Paste: paste values from external RTF (Alt, H, V, T)
  • Paste: paste values from external HTML (Alt, H, V, S, End, Enter)
  • Find/Replace: show replace window (Alt, E, E)
  • UsefulCmd: set print area (Alt, P, R, S)
  • UsefulCmd: clear print area (Alt, P, R, C)
  • UsefulCmd: sort ascending (Alt, A, S, A)
  • UsefulCmd: sort descending (Alt, A, S, D)
  • UsefulCmd: remove duplicates (Alt, A, M, Shift+Tab, Shift+Tab)

Bug-fix validation (customized ribbon)

  • Remove "Cells" group from Home tab, verify insert/delete row/column still works
  • Remove "Font" group from Home tab, verify font size increase/decrease still works
  • Remove "Alignment" group from Home tab, verify align left/center/right still works
  • Remove "Number" group from Home tab, verify indent/decimal/comma style still works
  • Remove "Editing" group from Home tab, verify AutoSum still works
  • Strip Data tab, verify sort/filter commands still work

🤖 Generated with Claude Code

Alt-keystroke commands that simulate ribbon KeyTip navigation break
when users customize their ribbon layout. Replace with direct object
model calls or ExecuteMso, which work regardless of ribbon state.

Addresses sha5010#57

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant