You'll need to replace the button with a SecureActionButton copy of it.
Notice CharacterMicroButton doesn't use an OnClick handler, but it should work all the same.
lua Code:
local old,new=CharacterMicroButton,CreateFrame("Button","CharacterMicroButton","MainMenuBarArtFrame","SecureActionButton MainMenuBarMicroButton");
CharacterMicroButton=new;-- CreateFrame() will only create the button with the name set and not overwrite the global
-- Position and steal portrait texture
new:SetAllPoints(old);
MicroButtonPortrait:SetParent(new);
old:Hide();
-- Copy script handlers and apply OnLoad
new:HookScript("OnMouseDown",old:GetScript("OnMouseDown"));
new:HookScript("OnMouseUp",old:GetScript("OnMouseUp"));
new:HookScript("OnEvent",CharacterMicroButton_OnEvent);
CharacterMicroButton_OnLoad(new);
-- Now for the secure stuff
new:SetAttribute("type","macro");-- Set to run a macro
new:SetAttribute("macrotext",SLASH_CANCELFORM1);-- Make sure we use the localized slash command