Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-08-2013, 10:25 PM
Julia Julia is offline Using macro to add variable number of rows to a protected word table Windows 7 32bit Using macro to add variable number of rows to a protected word table Office 2010 32bit
Novice
Using macro to add variable number of rows to a protected word table
 
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using macro to add variable number of rows to a protected word table Mail Merge to create specific number of table rows flackend Mail Merge 4 12-01-2023 02:49 PM
Using macro to add variable number of rows to a protected word table 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
Using macro to add variable number of rows to a protected word table adding rows to word table hklein Word VBA 4 07-18-2011 12:21 AM
Using macro to add variable number of rows to a protected word table Fixing number or rows in a table burnsie Word 2 07-12-2011 02:59 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:25 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft