I have this macro to fill a form (an RTF document) with {FORMTEXT} fields. I found no way to access these fields directly, so this is what I came up with:
Code:
Sub FillForm()
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Comments"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="No comment"
Selection.MoveRight Unit:=wdCell
Selection.EndKey Unit:=wdLine
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.InsertDateTime DateTimeFormat:="MMMM dd, yyyy", InsertAsField:=False
Selection.MoveRight Unit:=wdCell
Selection.EndKey Unit:=wdLine
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.TypeText Text:="Alyb"
ActiveDocument.save
Application.Quit SaveChanges:=wdDoNotSaveChanges
End Sub
The strange thing is that Word for Mac (Microsoft® Word for Mac, Version 16.91 (24111020)) doesn't quit after running the macro. How come?
And I have one other question: every time I change a macro, I have to grant Word for Mac access to the normal.dotm. Can this step be automated/prevented?