![]() |
#16
|
|||
|
|||
![]() Thanks Graham. Almost there. If I have ten sets of fields in the form and run the macro, it successfully inserts a new set of field just below the current cursor position, however, it returns the cursor to the top set of fields so I have to tab through them all to get to the new set of fields just entered. |
#17
|
||||
|
||||
![]()
Name the fields added separately and select the first of them e.g.
Code:
Option Explicit Sub CreateTextField() Dim oRng As Range Dim aFld As FormField, bFld As FormField If ActiveDocument.ProtectionType <> wdNoProtection Then ActiveDocument.Unprotect Selection.Paragraphs(1).Range.InsertParagraphAfter Set oRng = Selection.Paragraphs(1).Range.Next.Paragraphs(1).Range With oRng .ParagraphFormat.SpaceBefore = 3 .Collapse 1 Set aFld = .FormFields.Add(Range:=oRng, Type:=wdFieldFormTextInput) aFld.TextInput.EditType Type:=wdRegularText, Default:="Category", Format:="First capital" .End = aFld.Range.End .Font.Bold = True .Collapse 0 .Text = ": " .Font.Bold = False .Collapse 0 Set bFld = .FormFields.Add(Range:=oRng, Type:=wdFieldFormTextInput) bFld.TextInput.EditType Type:=wdRegularText, Default:="Detail", Format:="First capital" .End = bFld.Range.End .Collapse 0 aFld.Select 'select the first of the two added fields End With lbl_Exit: ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True Set oRng = Nothing Set aFld = Nothing Set bFld = Nothing Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#18
|
|||
|
|||
![]()
Perfect! Thanks so much.
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
sj80 | Word | 1 | 01-26-2016 10:50 PM |
![]() |
Cosmo | Word | 2 | 12-29-2015 11:54 AM |
![]() |
Eduardo Care | Word | 2 | 09-09-2015 03:11 PM |
![]() |
sunrise06 | Word | 9 | 05-02-2015 06:48 PM |
Filling in legacy field causes rest of line to move to next tab stop | rtrdom | Word | 5 | 12-14-2013 05:48 PM |