![]() |
#1
|
|||
|
|||
![]()
I have built a protected form in Word 2007 but the eventual user wants the facility to extend the number of rows themselves in certain tables as the 'standard' amout I have set out may not be sufficient for their needs which can vary from form to form. I knew I would have to utilise a macro to do this but this is new territory for me so I did some Googling and found a suitable macro script on another forum (see script at end of this post). I tested this out on a dummy document using a keyboard shortcut and it worked fine but when I use the macro on the proper form I get a Runtime error, even though the macro does add the extra row. The proper form is not complex as it only consists of the normal protection with unprotected text fields although it is around 10 pages in length. There are no other macros that might cause a conflict.
When I check the debug info, the line oFld(i).Result = "" is highlighted as being the problem. I have added the error and debug info below, along with the macro script. Hoping someone can shed some light on this for me. ================================================== ========================= Sub AddARow() Dim i As Integer Dim bProtected As Boolean Dim sNewRow As String Dim oFld As FormFields sNewRow = InputBox("Insert New Row", "New Row", "No") If Left(UCase(sNewRow), 1) <> "N" Then 'Unprotect the file If ActiveDocument.ProtectionType <> wdNoProtection Then bProtected = True ActiveDocument.Unprotect Password:="" End If With Selection .SelectRow .Copy .Paste .SelectRow Set oFld = Selection.Range.FormFields For i = 1 To oFld.Count oFld(i).Result = "" Next End With If bProtected = True Then ActiveDocument.Protect _ Type:=wdAllowOnlyFormFields, NoReset:=True, Password:="" End If End If End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
EllieW | Word | 3 | 08-16-2011 11:27 AM |
![]() |
waldux | Word VBA | 1 | 03-04-2011 11:25 PM |
MS Word 2007 error when trying to upload .doc or .docx to a webpage | heretical1 | Word | 0 | 10-06-2010 12:20 PM |
Runtime error 5487 - Word cannot complete the save to to file permission error | franferns | Word | 0 | 11-25-2009 05:35 AM |
Receive error cannot open this form because an error occurred in BCM 2007 | bornhusker | Outlook | 0 | 06-01-2009 10:28 AM |