View Single Post
 
Old 01-08-2013, 10:25 PM
Julia Julia is offline Windows 7 32bit Office 2010 32bit
Novice
 
Join Date: Jan 2013
Posts: 1
Julia is on a distinguished road
Default Using macro to add variable number of rows to a protected word table

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 :-)
Reply With Quote