Adjusting Cell properties by macro?

J

JAnderson

Greetings,

I'm very familiar with Excel macros and VBA, but new to this with Word. I
want to record a macro to adjust cell properties, but when I start recording
the macro, I lose the ability to right-click! (Anyone know how to overcome
this?)

Anyway, for various reasons, I need a macro to adjust cell margins.
Normally, this is done by right-clicking a cell, selecting "Table
Properties"-->Cell tab-->Options button-->Cell margins, and setting all
values to zero. (Default value is 0.08 for two of the margins.)

Does anyone have a suggestion as to a good way to create a macro for this
menial task? Thanks!
 
J

Jay Freedman

Greetings,

I'm very familiar with Excel macros and VBA, but new to this with Word. I
want to record a macro to adjust cell properties, but when I start recording
the macro, I lose the ability to right-click! (Anyone know how to overcome
this?)

Anyway, for various reasons, I need a macro to adjust cell margins.
Normally, this is done by right-clicking a cell, selecting "Table
Properties"-->Cell tab-->Options button-->Cell margins, and setting all
values to zero. (Default value is 0.08 for two of the margins.)

Does anyone have a suggestion as to a good way to create a macro for this
menial task? Thanks!

Before going on, I'll note that you can use the menu item Table > Table
Properties (in Word 2007, Table Tools > Layout > Properties) instead of the
right-click context menu while recording, and you'll get code almost identical
to the following (but without the verification that the cursor is in a table):

Sub demo()
If Not Selection.Information(wdWithInTable) Then Exit Sub

With Selection.Cells(1)
.LeftPadding = 0
.RightPadding = 0
.TopPadding = 0
.BottomPadding = 0
End With
End Sub
 
F

fumei via OfficeKB.com

BTW: when recording a macro, and you need a right-click and can not seem to
get it, use Shift-F10.

This is the standard Windows application keyboard equivalent to a right-click.
It allows you to do most (but not all) right-click operations during macro
recording.
Couldn't have been a more perfect answer. Thank you!
[quoted text clipped - 32 lines]
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top