Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Feb 2016
    Thanked 0 Times in 0 Posts

    How to select an object if you're recording a macro (word 2013)


    I don't know how to program in VBA but I have done macros in the past by recording them. But I can't get this one started.

    What I need is to be able to format a screen shot that I've pasted into a Word document so that it is a certain size and has a border of a certain number of pixels.

    I have found the keyboard strokes for getting up to the ribbon and doing the formatting but - I can't start to record because I can't find a way to select the darn object using the keyboard! (just clicking it doesn't work and if you click it first, it doesn't stay selected once you start the macro)

    If there is no way to do this, could you refer me to a basic book on learning VBA?

    Thanks, in advance,


  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Melbourne, Victoria, Australia
    Thanked 295 Times in 267 Posts
    You can select an inline shape by putting your cursor in front and then while the macro is recording press Shift-Right Arrow.

    It is better to learn some vba though and make use of the Intellisense features of the VBA editor.

    Assuming your graphics are inline shapes, the following code might get you started
    Dim aPict as InlineShape
    For each aPict in Selection.InlineShapes
      aPict.Borders.OutsideLineWidth = wdLineWith225pt
      aPict.Borders.OutsideColor = wdColorRed
      aPict.Width = CentimetersToPoints(10)
    Next aPict
    Note that setting the size explicitly is problematic since the aspect ratios of screen captures will vary wildly. You don't want to distort them so you might need to use the .ScaleWidth and .ScaleHeight instead.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Pacific Grove, California, USA
    Thanked 40 Times in 34 Posts
    Suzan, are you familiar with the VB Editor? If so, reviewing the results of macros you've recorded will start you on the way to understanding the structure of VBA. If you've never been in the VB Editor, let us know.

    You can do a lot more useful things writing VBA code directly, than you can in a recorded macro, as Andrew's code demonstrates. If you're interested in macros and what they can do, it's worth it to start learning it in earnest. If not, it might prove to be more work than you really want to take on.

    This article on getting started with Word VBA from Microsoft is for Word 2010, but you'll find it applicable to 2013. If that doesn't suit, you might consider this book. Again, different version of Word, and while MSFT does add and remove commands, you'll find most of it applies to 2013.

    HTH, Kim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts