View Single Post
 
Old 03-09-2015, 05:33 AM
BruceM BruceM is offline Windows 7 64bit Office 2010 32bit
Advanced Beginner
 
Join Date: Feb 2015
Posts: 41
BruceM is on a distinguished road
Default Macros to move objects prevents moving same objects with arrow keys

I make frequent use of macros stored in an Add-In to perform various actions with text boxes and other graphic elements. I have a custom ribbon tab for macros, with the macros added as buttons on the ribbon.

An example is centering a graphic:

Code:
 
Public Sub CenterGraphic()

  Selection.ShapeRange.Left = wdShapeCenter
 
End Sub
After running the macro I can no longer use the arrow keys to nudge the object. If I move the object with the mouse, I can then use the arrow keys to nudge it, but immediately after running the macro the arrow keys will not move the graphic.

The code above is very simple, and perhaps I could find a button to put onto a ribbon to accomplish the same thing. However, other macros are a little more involved. One that I use often wraps the text top and bottom, with user prompts (input boxes) for the distance. The default is 1, which is 0.1 inches, but other values can be chosen as needed. After running that macro I cannot nudge the graphic with the arrow keys. In some situations I cannot set the size from the ribbon, either, but I can set it from the More Layout Options dialog. I haven't quite sorted out all of the variants of what does and doesn't work under various scenarios, but I do know that running a macro that performs an action on a graphic sometimes overrides the ability to perform keyboard and ribbon actions on the same graphic. It always overrides the use of arrow keys to move the graphic.

This only happens with docx files. With doc files, running the macro does not have the effect I have described.

Any ideas on what is happening here?
Reply With Quote