![]() |
|
#1
|
|||
|
|||
|
Hi there, I am trying to add a row or rows to a table in a protected word document. I have created the following macro that unprotects the document, adds the row, copies some drop-down fields into the row and then re-enforces the protection.
Sub Macro2() ' ' Macro2 Macro ' ' ActiveDocument.Unprotect Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveDown Unit:=wdLine, Count:=1 Selection.MoveRight Unit:=wdCharacter, Count:=1 Selection.InsertRows 1 Selection.Collapse Direction:=wdCollapseStart Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.TypeText Text:="2" Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.MoveRight Unit:=wdCharacter, Count:=2 Selection.MoveRight Unit:=wdCharacter, Count:=5, Extend:=wdExtend Selection.Copy Selection.MoveDown Unit:=wdLine, Count:=1 Selection.PasteAndFormat (wdPasteDefault) Selection.MoveUp Unit:=wdLine, Count:=1 If ActiveDocument.ProtectionType = wdNoProtection Then ActiveDocument.Protect _ Type:=wdAllowOnlyFormFields, NoReset:=True End If End Sub My issue is that I would like to run this macro (and other macros that add more lines) based on a number selected by the user in a drop-down box. i.e. User selects #of items : '3' from a drop-down box. Based on the fact that '3' was selected, I want 3 rows added to the table. It appears that I can only choose one macro to run on exit of the field, and not have a range of macros that are run based on the users selection. Can anyone offer some assistance with this? Thanks :-) |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Mail Merge to create specific number of table rows
|
flackend | Mail Merge | 4 | 12-01-2023 02:49 PM |
Allow user to add rows to Word '03 table....how?
|
PMR | Word Tables | 2 | 05-18-2012 06:16 AM |
| Help with VBA macro - Variable input | sc30317 | Excel Programming | 0 | 08-31-2011 01:00 PM |
adding rows to word table
|
hklein | Word VBA | 4 | 07-18-2011 12:21 AM |
Fixing number or rows in a table
|
burnsie | Word | 2 | 07-12-2011 02:59 AM |