Triggering Save As dialog box when updating a dotm file

visi 0 Reputation points
2024-05-07T12:13:43.56+00:00

I have a macro that triggered a Save As dialog box whenever a custom dotm file was opened. I made a minor change to the macro, but now the Save As dialog box is not triggered when I open the dotm file. Can anyone provide guidance on what I might be missing? Thank you.

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,666 questions
Word Management
Word Management
Word: A family of Microsoft word processing software products for creating web, email, and print documents.Management: The act or process of organizing, handling, directing or controlling something.
905 questions
{count} votes

1 answer

Sort by: Most helpful
  1. visi 0 Reputation points
    2024-05-07T18:11:23.52+00:00

    Here is the macro:

    Sub AutoOpen()
        If ActiveDocument.CustomDocumentProperties.Count = 0 Then
            ActiveDocument.CustomDocumentProperties.Add Name:="AlreadyProcessed", LinkToContent:=False, Value:=1, Type:=msoPropertyTypeBoolean
            Call FormatCaptions
            Call CentreFigures
            Call SaveDoc
            Selection.HomeKey Unit:=wdStory
        End If
    End Sub
    
    Private Sub FormatCaptions()
    
    ...
    Private Sub CentreFigures()
    ...
    
    Private Sub SaveDoc()
        If ActiveDocument.Bookmarks.Exists("Title") Then
            ActiveDocument.BuiltInDocumentProperties("Title") = ActiveDocument.Bookmarks("Title").Range.Text
        Else
            ActiveDocument.BuiltInDocumentProperties("Title") = ActiveDocument.Name
        End If
        ActiveDocument.BuiltInDocumentProperties("Company") = "XYZ"
        ActiveDocument.BuiltInDocumentProperties("Author") = "ABC"
        ActiveDocument.BuiltInDocumentProperties("Last author") = "LMN"
        ActiveDocument.BuiltInDocumentProperties("Subject") = ""
        ActiveDocument.BuiltInDocumentProperties("Keywords") = ""
        ActiveDocument.BuiltInDocumentProperties("Category") = ""
        
        With Dialogs(wdDialogFileSaveAs)
            .Name = ActiveDocument.BuiltInDocumentProperties("Title")
            .Format = wdFormatXMLDocument  ' actually saves file as a DOCX
            If .Show Then
                .Execute
            End If
        End With
            
    End Sub
    
    0 comments No comments