Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Macro Recorder

0 views
Skip to first unread message

visual Basic

unread,
Dec 24, 2001, 7:35:15 PM12/24/01
to
I write code and use Excel's Macro Recorder often. I now want to start
writing some code in Word. To help me learn some of it I would like to use
the macro recorder. The problem is that with the recorder running it seems
that I can not do anything (well almost). As an example, I have a picture
in my document. I can select this picture and resize it change it's
formatting conditions,etc... When I start the macro recorder, I can not
even select the picture. Is this normal. I have Office 2000 running on
win98 second edition with all the available patches (the ones that I know
about anyways). I guess what I am asking is why can I not select things
like pictures or even use my right mouse button???

Please help.

Mike Wakeman


Mark Tangard

unread,
Dec 25, 2001, 4:10:08 AM12/25/01
to
Hi Mike,

The macro recorder can't record most non-menu-related mouse movements,
and unfortunately, actions like selecting pictures fall into that
category. While recorded code is still sometimes useful for getting
hints at writing VBA code, the code the recorder produces for Word is
often very inefficient, and as you've seen, there's a big subset of
actions it simply can't duplicate at all.

In Excel the utility of the recorder is greater, partly because a
spreadsheet is inherently a more rigid, more code-receptive framework
than a word processing document. Writing Word VBA for things like
graphics tends to require a bit more thorough understanding of how
the Word object model works. For one thing, you only rarely want
to *select* a picture in a Word document; it's easier and cleaner
just to refer to it as part of its "collection." For example, if
your picture is the first or only picture in the document, the line:

ActiveDocument.InlineShapes(1).ScaleHeight = 150

will resize it to 150% of its height. (This assumes the picture was
inserted "inline," which is the default for Word 2000.) An even more
typical use of VBA code for this sort of operation is to insert the
picture itself, simultaneously assigning it an object variable, which
can then be used to refer to it, e.g.:

Dim myshape As InlineShape
Set myshape = ActiveDocument.InlineShapes. _
AddPicture(FileName:="C:\My Pictures\MerryChristmas.jpg")
myshape.ScaleHeight = 150

Adjusting from Excel VBA to Word VBA (or vice versa) is unfortunately
nowhere near as easy it seems like it should be, and frustration at
the initial shock is normal in either direction.

Hope this helps a little.

-- Mark Tangard <mtan...@speakeasy.net>, Microsoft Word MVP ------------
-- See the MVP FAQ at http://www.mvps.org/word --------------------------
----------------- "Life is nothing if you're not obsessed." --John Waters
-------------------------------------------------------------------------
Please reply ONLY TO THE NEWSGROUP. Note: MVPs do not work for Microsoft.

visual Basic

unread,
Dec 25, 2001, 9:17:26 AM12/25/01
to
Mark,

Thanks for the feedback You are definitely right on the frustration part
especially after using Excel as long as I have.

Regards,

Mike Wakeman


"Mark Tangard" <mtan...@speakeasy.net> wrote in message
news:3C284270...@speakeasy.net...

0 new messages