Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-03-2022, 08:58 AM
brent chadwick brent chadwick is offline Tab issues with Word Mac 365 Windows 8 Tab issues with Word Mac 365 Office 2013
Advanced Beginner
Tab issues with Word Mac 365
 
Join Date: Mar 2015
Posts: 86
brent chadwick is on a distinguished road
Default Tab issues with Word Mac 365

Hey Guys, this is for any Mac 365 users out there that have run into tab issues in form fields. The code below runs perfectly in Mac 2011 and Windows, but in Mac 2016,2019 and 365 deletes the default text in the first form field. I have tried a bunch of work-arounds with little success. Any suggestions welcome-Brent


Code:
Sub RLNaturalization()
   ' Naturalization Macro
  Application.ScreenUpdating = False
  Dim Rng As Range, FmFld As FormField
  Set Rng = Selection.Range
  With ActiveDocument
    Rng.Collapse wdCollapseStart
    'Dropdown Menu for Record Collection
    Set FmFld = .FormFields.Add(Range:=Rng, Type:=wdFieldFormDropDown)
    With FmFld
      .Name = "NaturalizationDD"
      .EntryMacro = ""
      .ExitMacro = "RLNaturalizationCC"
      .Enabled = True
      With .DropDown.ListEntries
        .Add Name:="Naturalization Records"
        .Add Name:="Declaration of Intent"
        .Add Name:="Petition For Naturalization"
      End With
    End With
    With Rng
      .End = FmFld.Range.End
      .Collapse wdCollapseEnd
    End With
    .Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=Pwd
    End With
    Set FmFld = Nothing: Set Rng = Nothing
  Application.ScreenUpdating = True
  End Sub
Code:
Sub RLNaturalizationCC()
  Application.ScreenUpdating = False
  Dim Prot As Variant, Rng As Range, FmFld As FormField
  Const Pwd As String = ""
  With ActiveDocument
    Prot = .ProtectionType
    If .ProtectionType <> wdNoProtection Then
      Prot = .ProtectionType
      .Unprotect Password:=Pwd
      Set Rng = Selection.Range
      Select Case .FormFields("NaturalizationDD").Result
      'Case for Declaration of Intent
        Case "Declaration of Intent"
        If InStr(Rng.Text, "Declaration of Intent") = 0 Then
         With Rng
          'Formfield for Firstname Lastname
          Set FmFld = .FormFields.Add(Range:=Rng, Type:=wdFieldFormTextInput)
          FmFld.TextInput.EditType wdRegularText, "Firstname Lastname", Format:="Title Case"
          With Rng
            .End = FmFld.Range.End
            .InsertAfter " petition for naturalization file, "
            .InsertAfter Chr(210) & "Petitions for Naturalization from the "
            .Collapse wdCollapseEnd
          End With
         'Formfield for Court of Naturalization
          Set FmFld = .FormFields.Add(Range:=Rng, Type:=wdFieldFormTextInput)
          FmFld.TextInput.EditType wdRegularText, "Court of Naturalization", Format:="Title Case"
          With Rng
            .End = FmFld.Range.End
            .InsertAfter ", "
            .Collapse wdCollapseEnd
          End With
          'Formfield for Term of Court
          Set FmFld = .FormFields.Add(Range:=Rng, Type:=wdFieldFormTextInput)
          FmFld.TextInput.EditType wdRegularText, "Term of Court"
          With Rng
            .End = FmFld.Range.End
            .InsertAfter ","
            .InsertAfter Chr(211) & " record "
            .Collapse wdCollapseEnd
          End With
          'Formfield for Record Number
          Set FmFld = .FormFields.Add(Range:=Rng, Type:=wdFieldFormTextInput)
          FmFld.TextInput.EditType wdRegularText, "XXX"
          With Rng
            .End = FmFld.Range.End
            .InsertAfter ", "
            .Collapse wdCollapseEnd
          End With
         'Formfield for Lastname
          Set FmFld = .FormFields.Add(Range:=Rng, Type:=wdFieldFormTextInput)
          FmFld.TextInput.EditType wdRegularText, "Lastname", Format:="Title Case"
          With Rng
            .End = FmFld.Range.End
            .InsertAfter "; declaration of intent, "
            .Collapse wdCollapseEnd
          End With
         'Formfield for Record Date
          Set FmFld = .FormFields.Add(Range:=Rng, Type:=wdFieldFormTextInput)
          FmFld.TextInput.EditType wdRegularText, "Record Date"
          With Rng
            .End = FmFld.Range.End
            .InsertAfter "."
            .Collapse wdCollapseEnd
             FmFld.ExitMacro = "RLUnlinkFieldsNonItalic"
              'Bookmark for End of Citation
             .Bookmarks.Add Name:="End"
          End With
          ActiveDocument.Bookmarks("Text1").Range.Fields(1).Result.Select
          End With
        End If
         'Case for Petition For Naturalization
        Case "Petition For Naturalization"
        If InStr(Rng.Text, "Petition For Naturalization") = 0 Then
         With Rng
          'Formfield for Firstname Lastname
          Set FmFld = .FormFields.Add(Range:=Rng, Type:=wdFieldFormTextInput)
          FmFld.TextInput.EditType wdRegularText, "Firstname Lastname", Format:="Title Case"
          With Rng
            .End = FmFld.Range.End
            .InsertAfter " petition for naturalization file, "
            .InsertAfter Chr(210) & "Petitions for Naturalization from the "
            .Collapse wdCollapseEnd
          End With
         'Formfield for Court of Naturalization
          Set FmFld = .FormFields.Add(Range:=Rng, Type:=wdFieldFormTextInput)
          FmFld.TextInput.EditType wdRegularText, "Court of Naturalization", Format:="Title Case"
          With Rng
            .End = FmFld.Range.End
            .InsertAfter ", "
            .Collapse wdCollapseEnd
          End With
          'Formfield for Term of Court
          Set FmFld = .FormFields.Add(Range:=Rng, Type:=wdFieldFormTextInput)
          FmFld.TextInput.EditType wdRegularText, "Term of Court"
          With Rng
            .End = FmFld.Range.End
            .InsertAfter ","
            .InsertAfter Chr(211) & " record "
            .Collapse wdCollapseEnd
          End With
          'Formfield for Record Number
          Set FmFld = .FormFields.Add(Range:=Rng, Type:=wdFieldFormTextInput)
          FmFld.TextInput.EditType wdRegularText, "XXX"
          With Rng
            .End = FmFld.Range.End
            .InsertAfter ", "
            .Collapse wdCollapseEnd
          End With
         'Formfield for Firstname Lastname
          Set FmFld = .FormFields.Add(Range:=Rng, Type:=wdFieldFormTextInput)
          FmFld.TextInput.EditType wdRegularText, "Firstname Lastname", Format:="Title Case"
          With Rng
            .End = FmFld.Range.End
            .InsertAfter "; petition for naturalization, "
            .Collapse wdCollapseEnd
          End With
         'Formfield for Record Date
          Set FmFld = .FormFields.Add(Range:=Rng, Type:=wdFieldFormTextInput)
          FmFld.TextInput.EditType wdRegularText, "Record Date"
          With Rng
            .End = FmFld.Range.End
            .InsertAfter "."
            .Collapse wdCollapseEnd
             FmFld.ExitMacro = "RLUnlinkFieldsNonItalic"
              'Bookmark for End of Citation
             .Bookmarks.Add Name:="End"
          End With
          End With
          ActiveDocument.Bookmarks("Text1").Range.Fields(1).Result.Select
          End If
        Case Else: Rng.Text = Chr(211)
      End Select
      .Protect Type:=Prot, Password:=Pwd, NoReset:=True
    End If
  End With
  Set FmFld = Nothing: Set Rng = Nothing
  Application.ScreenUpdating = True
  End Sub

Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting issues (numbering and other issues) in big document. Possibly corrupted. Can anyone help? Ida Word 9 07-26-2018 10:22 AM
Tab issues with Word Mac 365 Opening a Word 2010 .docx file with Word 2007 and Issues bwalshnl Drawing and Graphics 1 03-02-2017 04:13 AM
Tab issues with Word Mac 365 Word 2016 vs Word 2003 (issues I can't figure out) AdventureCapitliast Word 6 02-23-2017 06:23 AM
Combining Multiple Word Documents Heading/Figure Issues Word 2007 grantgibson45 Word 1 09-10-2012 11:00 PM
Issues with synchronization log causing send/receive issues WinSock64 Outlook 0 01-11-2011 11:29 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:37 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