Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-14-2024, 06:38 AM
amankap amankap is offline Triggering Save As dialog box when updating a dotm file Windows 10 Triggering Save As dialog box when updating a dotm file Office 2021
Novice
Triggering Save As dialog box when updating a dotm file
 
Join Date: May 2024
Posts: 8
amankap is on a distinguished road
Default Triggering Save As dialog box when updating a dotm file

I have a macro that triggers 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.




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
Reply With Quote
  #2  
Old 05-14-2024, 09:53 AM
gmaxey gmaxey is offline Triggering Save As dialog box when updating a dotm file Windows 10 Triggering Save As dialog box when updating a dotm file Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,602
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

]I don't see why your SaveDoc macro is not executed when you open the template.
You can try putting a stop in the AutoOpen macro then when your code hits the step, stop through (with the F8 key) and troubleshoot. Maybe the CustomDocumentProperties.Count is not = 0


[CODE]Sub AutoOpen()
Stop
If ActiveDocument.CustomDocumentProperties.Count = 0 Then
ActiveDocument.CustomDocumentProperties.Add Name:="AlreadyProcessed",
LinkToContent:=False, Value:=1, Type:=msoPropertyTypeBoolean
FormatCaptions
CentreFigures
SaveDoc
Selection.HomeKey Unit:=wdStory
End If
End Sub[/CODE
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 05-15-2024, 08:45 PM
Charles Kenyon Charles Kenyon is offline Triggering Save As dialog box when updating a dotm file Windows 11 Triggering Save As dialog box when updating a dotm file Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,474
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Why are you saving a copy of your .dotm?
Why not simply start a new document based on it?


Or, are you doing this so you have a backup?
Reply With Quote
  #4  
Old 05-21-2024, 11:14 AM
amankap amankap is offline Triggering Save As dialog box when updating a dotm file Windows 10 Triggering Save As dialog box when updating a dotm file Office 2021
Novice
Triggering Save As dialog box when updating a dotm file
 
Join Date: May 2024
Posts: 8
amankap is on a distinguished road
Default

Hi Greg, thanks for your response. I have added Stop but nothing changed.
Reply With Quote
  #5  
Old 05-21-2024, 11:18 AM
amankap amankap is offline Triggering Save As dialog box when updating a dotm file Windows 10 Triggering Save As dialog box when updating a dotm file Office 2021
Novice
Triggering Save As dialog box when updating a dotm file
 
Join Date: May 2024
Posts: 8
amankap is on a distinguished road
Default

Hi Charles,
I am saving a copy of a .dotm file because I need to add some functionality to the macro-enabled template. When I add the new functionality, the .dotm file stops triggering the Save As dialog when the file is opened.


To test what went wrong, I simply opened a working .dotm file, made a minor change to an existing comment line, and saved it.


Even this stops the function where opening the .dotm file results in the Save As dialog.


Regards,
Aman
Reply With Quote
  #6  
Old 05-21-2024, 11:22 AM
amankap amankap is offline Triggering Save As dialog box when updating a dotm file Windows 10 Triggering Save As dialog box when updating a dotm file Office 2021
Novice
Triggering Save As dialog box when updating a dotm file
 
Join Date: May 2024
Posts: 8
amankap is on a distinguished road
Default

Hi Greg,
I think, as you said, maybe the CustomDocumentProperties.Count is not 0.
Any input on how this can be fixed?


regards,
Aman
Reply With Quote
  #7  
Old 05-21-2024, 12:02 PM
gmaxey gmaxey is offline Triggering Save As dialog box when updating a dotm file Windows 10 Triggering Save As dialog box when updating a dotm file Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,602
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

If you added the Stop and then stepped through the code as I suggested, you will be all to tell if the .Count = 0 or not. If .Count is not = 0 then your code to save the document is not being called. What happens if you remove the If ... and the ... End If lines?


At least then the code to save will be called.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #8  
Old 05-21-2024, 12:07 PM
amankap amankap is offline Triggering Save As dialog box when updating a dotm file Windows 10 Triggering Save As dialog box when updating a dotm file Office 2021
Novice
Triggering Save As dialog box when updating a dotm file
 
Join Date: May 2024
Posts: 8
amankap is on a distinguished road
Default

I think now I know what I was doing wrong.
Let me try it and if it will work, will update the solution here.
Reply With Quote
  #9  
Old 05-21-2024, 01:11 PM
Charles Kenyon Charles Kenyon is offline Triggering Save As dialog box when updating a dotm file Windows 11 Triggering Save As dialog box when updating a dotm file Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,474
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Just to clarify:


You are opening the template for editing, not using it to create a new document?
You want a backup saved in addition to the one provided by the Save Backup function?


Again, the customary use of a document template is the creation of new documents based on the template, not opening the template.



Quote:
Originally Posted by amankap View Post
Hi Charles,
I am saving a copy of a .dotm file because I need to add some functionality to the macro-enabled template. When I add the new functionality, the .dotm file stops triggering the Save As dialog when the file is opened.


To test what went wrong, I simply opened a working .dotm file, made a minor change to an existing comment line, and saved it.


Even this stops the function where opening the .dotm file results in the Save As dialog.


Regards,
Aman
Reply With Quote
  #10  
Old 06-06-2024, 06:13 AM
amankap amankap is offline Triggering Save As dialog box when updating a dotm file Windows 10 Triggering Save As dialog box when updating a dotm file Office 2021
Novice
Triggering Save As dialog box when updating a dotm file
 
Join Date: May 2024
Posts: 8
amankap is on a distinguished road
Default

Thanks Greg! It worked.


Quote:
Originally Posted by gmaxey View Post
If you added the Stop and then stepped through the code as I suggested, you will be all to tell if the .Count = 0 or not. If .Count is not = 0 then your code to save the document is not being called. What happens if you remove the If ... and the ... End If lines?


At least then the code to save will be called.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
instance a new dotm file from a Word dotm file and save with new file name David Peck Word VBA 3 08-18-2023 06:47 AM
Save a range of pages as PDF/New Word file with SaveAs Dialog box popup smj.javid Word VBA 3 10-11-2021 04:11 AM
Triggering Save As dialog box when updating a dotm file save dialog box promt doesn't save file brmveen Word VBA 2 11-04-2015 12:51 AM
Updating active R/O templates (dot) and macros (dotm) gw1500se Word 0 05-27-2014 12:11 PM
Triggering Save As dialog box when updating a dotm file How to deactivate File Save dialog box KIM SOLIS Word 3 12-15-2013 12:30 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:28 AM.


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