Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-13-2018, 01:02 AM
mtagliaferri mtagliaferri is offline Save Document with Specific Text Windows Vista Save Document with Specific Text Office 2013
Novice
Save Document with Specific Text
 
Join Date: Mar 2018
Posts: 2
mtagliaferri is on a distinguished road
Default Save Document with Specific Text

I am trying to find a quick way when saving a document as Save As to save it with specific word that are phisically in the document, for example most of my documents contain name surname, staff number, date and subject.


I would like to not have to type the doc name when saving as, but display automatically the title as: Name Surname Staff Number date (YYYYMMDD) and then the subject or a text contained in the header of the document.

How can I achieve this?
Reply With Quote
  #2  
Old 03-13-2018, 05:41 AM
Charles Kenyon Charles Kenyon is online now Save Document with Specific Text Windows 10 Save Document with Specific Text Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,140
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

Version of Word?

I do this by having the information in Content Controls and having the Save and Save As commands intercepted to get that information.
That is the simplest way I have to identify information by location.

Here is the code I am using which picks up information in the first Content Control. Perhaps it will help.

Code:
Sub FileSave()
    ' Run as substitute for FileSave to add date to default document names
    ' Charles Kenyon 2017
    ' Appends date to Content Control Results when saving
        On Error Resume Next
   
    If Len(ActiveDocument.Path) > 0 Then
      ' The document has already been saved at least once.
      ' Just save and exit the macro.
      ActiveDocument.Save
      Exit Sub
    End If
    '
   
    '
    Dim strName As String, dlgSave As Dialog
    Set dlgSave = Dialogs(wdDialogFileSaveAs)
    strName = ActiveDocument.BuiltInDocumentProperties("Title").Value 'get name in title
'    
    strName = strName & " " & ActiveDocument.ContentControls(1).Range.Text 'add name from first content control
    strName = strName & " " & Format((Year(Now() + 1) Mod 100), "20##") & "-" & _
        Format((Month(Now() + 1) Mod 100), "0#") & "-" & _
        Format((Day(Now()) Mod 100), "0#") 'add date
'   
    With dlgSave
        .Name = strName
        .Show
    End With
End Sub

Sub FileSaveAs()
' Use above
    FileSave
End Sub
This is for use in a template for the document. If the document already has a name, it simply saves it. If not it assigns the name. The template has a base name in the Title document property. It also appends the current date in the format YYYY-MM-DD.

Install/Employ VBA Procedures (Macros)
Installing Macros
Reply With Quote
  #3  
Old 03-17-2018, 04:57 AM
mtagliaferri mtagliaferri is offline Save Document with Specific Text Windows Vista Save Document with Specific Text Office 2013
Novice
Save Document with Specific Text
 
Join Date: Mar 2018
Posts: 2
mtagliaferri is on a distinguished road
Default

Thanks Charles,
I am a bit confused, I have created a template (Template Letter One) pasted your code changed the contentControl to Name and have Letter One in the title in Properties when I saveAs it will use the text in the title within the properties.
On the Template Letter two is an example of what I a trying to achieve:

when entering Name & Surname & StaffNumber & Date the document should be saved as:
Name Surname StaffNumber Date Letter Two

Where Name and surname and staff number are retireved by the controls text the date is retrieved from the date control and should be in the format YYYYMMDD and finaly the title from the title properties of the document.

On a different note where is the above code stored? I was trying to find it when I open the document under VB but cannot find it!
Attached Files
File Type: dotx Template Letter One.dotx (20.2 KB, 6 views)
File Type: dotx Template Letter Two.dotx (21.4 KB, 7 views)
Reply With Quote
  #4  
Old 03-17-2018, 04:10 PM
Charles Kenyon Charles Kenyon is online now Save Document with Specific Text Windows 10 Save Document with Specific Text Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,140
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

I'm not looking at those. Neither would hold a macro as they are not .dotm files.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Save Document as Text File gerison Word VBA 5 11-27-2017 07:15 AM
Vba code to save document as pdf using document property text and rename folder. staicumihai Word VBA 1 12-21-2015 07:39 AM
Save Document with Specific Text Macro for word to add page break and specific text to end of document pizzaman1 Word VBA 6 11-14-2014 11:25 PM
Save Document with Specific Text Delete specific mass text on document JadeRisley Word 4 07-17-2013 11:11 PM
Save Document with Specific Text Deleteing specific text in word document ubns Word 1 05-31-2012 10:38 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:36 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft