View Single Post
 
Old 11-13-2024, 02:01 AM
Alyb Alyb is offline Mac OS X Office 2016 for Mac
Novice
 
Join Date: Jan 2023
Posts: 8
Alyb is on a distinguished road
Default Word for Mac doesn't quit

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?

Last edited by macropod; 11-19-2024 at 12:24 AM. Reason: Added code tags
Reply With Quote