Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #10  
Old 06-08-2016, 10:08 AM
gmaxey gmaxey is offline VBA Code to Insert Legacy Text Field Windows 7 32bit VBA Code to Insert Legacy Text Field Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,600
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

What is not working?

Code:
Sub CreateTextField()
'With the exception of this minor change you code seems to work fine.
If ActiveDocument.ProtectionType <> wdNoProtection Then ActiveDocument.Unprotect
Dim oRng As Range
Dim aFld As FormField
    Set oRng = Selection.Range
    With oRng
        .End = .Paragraphs(1).Range.End + 1
        .Collapse 0
        .Text = vbCr
        .Collapse 0
        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 aFld = .FormFields.Add(Range:=oRng, Type:=wdFieldFormTextInput)
        aFld.TextInput.EditType Type:=wdRegularText, Default:="Detail", Format:="First capital"
        .End = aFld.Range.End
        .Collapse 0
        'why do you need this? The bookmarks shouldn't be an issue
        'Do While .Paragraphs(1).Range.Bookmarks.Count > 0
        '    .Paragraphs(1).Range.Bookmarks(1).Delete
        'Loop
        .Select
    End With
lbl_Exit:
    Set oRng = Nothing
    Set aFld = Nothing
    Exit Sub
    
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Code to Insert Legacy Text Field Insert text form field help sj80 Word 1 01-26-2016 10:50 PM
VBA Code to Insert Legacy Text Field Variable text field code based on occurrences on each page Cosmo Word 2 12-29-2015 11:54 AM
VBA Code to Insert Legacy Text Field Grammar check into legacy forms > Text form field. Eduardo Care Word 2 09-09-2015 03:11 PM
VBA Code to Insert Legacy Text Field legacy Form Field 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

Other Forums: Access Forums

All times are GMT -7. The time now is 05:12 PM.


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