Results 1 to 3 of 3

Thread: Triggering Save As dialog box when updating a dotm file

  1. #1
    Junior Member
    Join Date
    May 2024
    Posts
    1
    Rep Power
    0

    Triggering Save As dialog box when updating a dotm file

    I have a macro that trigger a Save As dialog box whenever a custom dotm file is 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.

    Code:
    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

  2. #2
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,429
    Rep Power
    10
    Hello amankap
    Welcome to ExcelFox

    We don’t currently have many WORD experts passing here.
    If you are still looking for help, here is one Word Sub forum that I know has some clever Word people passing by recently, https://eileenslounge.com/viewforum.php?f=26

    I will take a guess that if you post this question there, then they would likely ask you the obvious question of what the minor change was that you made

    Alan
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

  3. #3
    Junior Member
    Join Date
    Aug 2024
    Posts
    7
    Rep Power
    0
    The issue is that ActiveDocument refers to the dotm file itself, not the document being opened. Try changing ActiveDocument to ThisDocument in your SaveDoc sub.

Similar Threads

  1. Convert selected file to XML and save.
    By dhivya.enjoy in forum Excel Help
    Replies: 7
    Last Post: 10-09-2013, 01:32 PM
  2. Replies: 4
    Last Post: 06-20-2013, 04:25 PM
  3. Save Worksheets As New File To Specific Folder
    By k0st4din in forum Excel Help
    Replies: 18
    Last Post: 06-08-2013, 04:24 PM
  4. Excel VBA Macro To Open A File Through Browse Dialog Box
    By Safal Shrestha in forum Excel Help
    Replies: 2
    Last Post: 04-05-2013, 12:59 PM
  5. Save File In CSV Format VBA
    By Raj Kumar in forum Excel Help
    Replies: 3
    Last Post: 06-01-2011, 07:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •