Creating a custom Macro in 07

  • Thread starter Thread starter Nat
  • Start date Start date
N

Nat

Hi,

I know how to create a macro in Word, however, I have a slight twist. What
I am trying to do is create a macro for someone (who does not like menus;
right-click or other) to insert a new row at the end of a word table. I
created a macro but it only adds 1 row, unless I highlight multiple rows when
recording the macro.

If you just highligt number of rows, right click and insert it will insert
X number of new rows. Can that functionality be created via macro as well?

Just curious is all. If it involves too much programming it might be over
my head.

thanks in advance..
 
The recorder is hopeless for a job like this (as it is for many
purposes). It's fairly simple to write the VBA from scratch, like
this:

Sub AddRows()
Dim nRows As Long

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

For nRows = 1 To Selection.Rows.Count
Selection.Tables(1).Rows.Add
Next
End Sub
 
Jay,

Thanks so much for that bit of code. THAT IS PERFECT, Is there any
literature that you are aware of which I could read that was introductory in
nature? I am no programmer, but I would enjoy basic scripting if possible.
Regardless, I really appreciate your assistance in this matter.

Nat
 

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

Back
Top