VBA: Refer to Excel Undolist language independent -
i have used excel macro automatically pastes info values, undoing pasting , pasting value. code:
option explicit private sub workbook_sheetchange(byval sh object, byval target range) dim undolist string application.screenupdating = false application.enableevents = false on error goto whoa '~~> undo list capture lastly action performed user undolist = application.commandbars("standard").controls("&undo").list(1) '~~> check if lastly action not paste nor autofill if left(undolist, 5) <> "paste" , undolist <> "auto fill" _ goto letscontinue '~~> undo paste user did not clearing '~~> clipboard copied info still in memory application.undo if undolist = "auto fill" selection.copy '~~> pastespecial preserve formats on error resume next '~~> handle text info copied website target.select activesheet.pastespecial format:="text", _ link:=false, displayasicon:=false target.pastespecial paste:=xlpastevalues, operation:=xlnone, _ skipblanks:=false, transpose:=false on error goto 0 '~~> retain selection of pasted info union(target, selection).select letscontinue: application.screenupdating = true application.enableevents = true exit sub whoa: msgbox err.description resume letscontinue end sub
i using english language excel version works fine, when other users, e.g. have high german excel version paste something, procedure error in line:
undolist = application.commandbars("standard").controls("&undo").list(1)
i guess undo command named differently in german. there way define undo list independent of language user using?
use control's id number instead.
debug.print application.commandbars("standard").controls("&undo").id => 128 debug.print application.commandbars("standard").findcontrol(id:=128).caption => &undo
excel-vba
No comments:
Post a Comment