+ Reply to Thread
Results 1 to 2 of 2

Word Template New Document Save on Open

  1. #1
    Registered User
    Join Date
    02-05-2019
    Location
    St. Louis, MO
    MS-Off Ver
    365
    Posts
    13

    Word Template New Document Save on Open

    I have a template that I would like to save automatically as a macro enabled document with the file name "iSolved Newsletter Release"in the following location: M:\2019 Email Campaigns\iSolved Release upon the open of a new document. I'm having difficulty with some code I have found to help set the document as macro enabled, but I cannot get the name and location to set.

    I am unable to upload the .docm file so below is my current code. I would also like to make this new file delete altogether after a date I have set as content control. Thank you so much in advance!

    Option Explicit

    Dim WithEvents App As Application

    Private Sub App_DocumentBeforeSave(ByVal Doc As Document, _
    SaveAsUI As Boolean, Cancel As Boolean)
    'This event runs on all documents, so be sure we get our own
    If Doc.AttachedTemplate.Name = ThisDocument.Name Then
    'If never saved or user does a "save as"
    If SaveAsUI Then
    With Application.FileDialog(msoFileDialogSaveAs)
    'The second filter is the DOCM filetype
    .FilterIndex = 2
    'Show the dialog
    .Show
    'Save the file as the user has choosen
    .Execute
    End With
    'Cancel the original dialog
    Cancel = True
    End If
    End If
    End Sub

    Private Sub Document_New()
    Set App = Application
    With Dialogs(wdDialogFileSaveAs)
    .Name = "M:\2019 Email Campaigns\iSolved Release"
    .Show
    End With
    ActiveDocument.SaveAs FileName:="M:\2019 Email Campaigns\iSolved Release"
    End Sub

    Private Sub Document_Open()
    Set App = Application
    End Sub

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Word Template New Document Save on Open

    If you're using a template, I can't see what the point would be of saving any documents produced from it as macro-enabled. Even documents saved in the docx format automatically have access to any code in the template and saving in the docm (macro-enabled) format doesn't add the code to it. As for the automatic save with the designated filename, use a Document_New macro in the template.

    As for the automatic deletion, a date stored in the document won't automatically result in that document's deletion when that date is reached, regardless of what you use for the date container. At the very least, someone would have to open that file and let the relevant macro run. If you want to ensure particular files are deleted once a given date is reached, you'd do far better to use a Windows script that runs automatically every day.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. open, edit, and save a word document based on user response in excel 2010 VBA
    By cmccabe in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-19-2016, 03:13 PM
  2. Replies: 1
    Last Post: 01-18-2014, 09:32 PM
  3. [SOLVED] open a word document and save it as html
    By Vagelisr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-01-2013, 03:12 AM
  4. Replies: 1
    Last Post: 03-30-2013, 01:36 PM
  5. open excel source document in background when i open word document
    By hootiebsc in forum Word Programming / VBA / Macros
    Replies: 5
    Last Post: 03-22-2013, 07:50 PM
  6. Word browsing folder and open txt files in word document.
    By naseerrahaman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-16-2013, 03:38 AM
  7. Replies: 0
    Last Post: 06-07-2012, 02:21 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1