Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-19-2014, 12:12 PM
deepgreen deepgreen is offline Insert identifiers in AutoText snippet. Microsoft word Windows 8 Insert identifiers in AutoText snippet. Microsoft word Office 2013
Novice
Insert identifiers in AutoText snippet. Microsoft word
 
Join Date: Jan 2014
Posts: 8
deepgreen is on a distinguished road
Default Insert identifiers in AutoText snippet. Microsoft word

I have define some AutoText blocks with no problem. Now I need to insert some sort of identifier** along with the AutoText block.

** by identifier I mean: number or letter preferably as static text, unique to the document. For example current time will work.

Example usage:
  • I insert a table with the AutoText feature
  • The first row of the table has an identifier which is unique to the document and static (wont update)



It would be wonderful to avoid macros. if a macro is the only way how can it be inserted in the AutoText snippet?

Cross-posted at IT Pro Discussion http://social.technet.microsoft.com/...ord?forum=word

Thanks in advance

Last edited by deepgreen; 01-19-2014 at 03:57 PM.
Reply With Quote
  #2  
Old 01-19-2014, 01:01 PM
Charles Kenyon Charles Kenyon is offline Insert identifiers in AutoText snippet. Microsoft word Windows 7 64bit Insert identifiers in AutoText snippet. Microsoft word Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,165
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

You could add a CreateDate field formatted however you want.
Using Date Fields in Microsoft Word

This field is linked to the date (and time) that a document is initially created. Seconds can be included and it need not display as a typical date and time. Note that using SaveAs on such a document changes this date. You could, though, unlink the field after it is inserted to freeze it even if SaveAs is later used. (Ctrl+Shift+ F11) unlinks fields.

No macros are required.

Cross-posted at IT Pro Discussions

Last edited by Charles Kenyon; 01-19-2014 at 02:51 PM. Reason: cross-posting link added
Reply With Quote
  #3  
Old 01-19-2014, 04:02 PM
deepgreen deepgreen is offline Insert identifiers in AutoText snippet. Microsoft word Windows 8 Insert identifiers in AutoText snippet. Microsoft word Office 2013
Novice
Insert identifiers in AutoText snippet. Microsoft word
 
Join Date: Jan 2014
Posts: 8
deepgreen is on a distinguished road
Default

Sorry for the cross-posting I am seeking for a quick answer and thought the forums were independent. I updated my initial post to include the link

Regarding your reply. I evaluate that option but it does not work:
1) Because too much user interaction is required, first you need to add the field and then unlink
2) Because i need multiple distinct identifiers on the same document.
3) I need the identifier to remain unchanged even when the document is changed, reopen or resaved.

The one that will probably work is “insert date time” (the static version: the date is inserted as text). Is there any way to insert it automatically along an AutoText?

Thanks for your support!
Reply With Quote
  #4  
Old 01-19-2014, 08:56 PM
Charles Kenyon Charles Kenyon is offline Insert identifiers in AutoText snippet. Microsoft word Windows 7 64bit Insert identifiers in AutoText snippet. Microsoft word Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,165
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

The need for multiple identifiers in one document means CreateDate will not work. You didn't mention that before.

The only way to change the CreateDate field is to use SaveAs. Changing, opening, resaving do not change it. No one inserts the field, they insert your AutoText. The field is a part of your AutoText. It is the "marker" you requested.

Instead, use a DATE field. Add something like:

{ Quote “MyAutoTextMarker” }{ DATE \@ "yyyyMMddhhmmss" }


as a part of your AutoText Entry.

When inserted, that would look like this: MyAutoTextMarker20140119101758

When the AutoText is inserted. Select it and press Ctrl+Shift+F11. (Ctrl+6 on the keyboard - not numeric keypad - does the same thing.)

Anything more automatic is going to involve a macro.

You could put a FILENAME field in there as well, but that would depend on the document already having a name before the field is unlinked.

Do what you wish.
Reply With Quote
  #5  
Old 01-20-2014, 07:04 AM
deepgreen deepgreen is offline Insert identifiers in AutoText snippet. Microsoft word Windows 8 Insert identifiers in AutoText snippet. Microsoft word Office 2013
Novice
Insert identifiers in AutoText snippet. Microsoft word
 
Join Date: Jan 2014
Posts: 8
deepgreen is on a distinguished road
Default

Charles I really appreciate your help, using your insights I am almost there.

Is there any way to automate the Ctrl+Shift+F11 step?. The user will almost certain forget to do it.

If a macro is the only way, could you provide some feedback on how to integrate with the autotext? Perhaps a macro that could be triggered after inserting an auto text and loop through all date fields and unlink them? Is that possible?

In this document there is some information about macros that execute on document close: http://word.mvps.org/FAQs/MacrosVBA/DocumentEvents.htm

Other question: I am really concern about the user experience, until now I just distribute a Word template (dotx) and all works wonderful. No special authorization or security warnings are shown. If I use a macro could I expect some warning?

Thanks.

Last edited by deepgreen; 01-20-2014 at 08:11 AM.
Reply With Quote
  #6  
Old 01-20-2014, 08:48 AM
Charles Kenyon Charles Kenyon is offline Insert identifiers in AutoText snippet. Microsoft word Windows 7 64bit Insert identifiers in AutoText snippet. Microsoft word Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,165
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

Quote:
Originally Posted by deepgreen View Post

Is there any way to automate the Ctrl+Shift+F11 step?. The user will almost certain forget to do it.
Yes. It is called a macro.

You could include a MacroButton Field as a part of your AutoText entry. That could run a macro which deletes the macrobutton field and unlinks your fields that are entered.

You could have a QAT button in your template to run a macro that itserts your AutoText and unlinks the fields.

You could have your own AutoText gallery in your template and have a macro or macros that use that gallery in a custom ribbon tab. Customize the Ribbon (It doesn't take rocket science)

This stuff can all be done. It depends on how much work you want to do. It may be simpler to train the user.

Quote:
Originally Posted by deepgreen View Post
Other question: I am really concern about the user experience, until now I just distribute a Word template (dotx) and all works wonderful. No special authorization or security warnings are shown. If I use a macro could I expect some warning.
This all depends on the level of control you have over the user settings. First, you do NOT want macro blocking turned off. You want your template and its code to be trusted. Can you put your template in a trusted location? Can you sign your template so that it will be trusted by the user's system?

If you can get a macro to run the on-close event would work as a' handler so you would not have to get the user to intentionally do anything (except perhaps to allow macros to run).

Graham Mayor has a page on Installing Macros that includes a macro to update all fields in a document. That could be converted to unlink Date fields. Note, it would unlink all date fields.

Here is one I have not tested. It could be called by the document close event.

Code:
Private Sub DateFieldUnlinkAllStory()
'   Written by Charles Kyle Kenyon 20 January 2014
'   help from Jezebel
'   All Story Date Field Unlinker
    Dim oField As Field
    Dim oStory As Range
'    On Error Resume Next
    For Each oStory In ActiveDocument.StoryRanges
    ' This goes into headers and footers as well as the regular document
        Do
            For Each oField In oStory.Fields
                If oField.Type = wdFieldDate Then
                    oField.Unlink
                End If
            Next oField
            Set oStory = oStory.NextStoryRange
        Loop Until oStory Is Nothing
    Next oStory
End Sub
That would not change CreateDate, SaveDate, or PrintDate fields.
Reply With Quote
  #7  
Old 01-20-2014, 12:48 PM
deepgreen deepgreen is offline Insert identifiers in AutoText snippet. Microsoft word Windows 8 Insert identifiers in AutoText snippet. Microsoft word Office 2013
Novice
Insert identifiers in AutoText snippet. Microsoft word
 
Join Date: Jan 2014
Posts: 8
deepgreen is on a distinguished road
Default

Hi Charles, first I need to thank you for so much help!!!

The work on my end it’s not a problem, I just want the user experience to be as smooth as possible.

Let me tell you what I did…
1) I created a template .dotx
2) In that template I stored all the Auto Text entries
3) Using the custom ui editor for Office I added a custom ribbon menu that displays the auto text gallery on the home tab (so the user don’t have to go around looking for that)

Now in each auto text entry I need to insert an identifier (unique to the document) and I am stuck there.

Regarding your suggestion to insert a macro button, I don’t really like it since the user still needs to press it. I would rather add a shortcut to insert date (static version) and instruct users to insert the date.

Regarding the level of control to settings….. I have little to none. The template will be distributed using skydrive, we got digital certificates but are internal to our country (not recognized by an international authority). So in the case the template is distributed as is? What’s the warning level I should expect?

I really like the snippet you write to unlink all date fields. That could be my final option, attach that piece of code to the save event?. I should try that soon and be back with the results.

Many thanks for the help!
Reply With Quote
  #8  
Old 01-20-2014, 05:29 PM
Charles Kenyon Charles Kenyon is offline Insert identifiers in AutoText snippet. Microsoft word Windows 7 64bit Insert identifiers in AutoText snippet. Microsoft word Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,165
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

The date and time will be unique to when the AutoText was inserted, but not to the document unless you put a document identifier in it. Look also into document variables which can be inserted in your templates. Again, though, modifying them requires vba.

You can expect some problems with your code running. Some users may have their machines set up to reject all macros without notice have no trusted locations.

Does your custom ribbon require code? If so, it may not work on those machines. Consider distributing a separate setup procedure with your template in a zip file with the template.

You can have an icon for a custom AutoText gallery on the QAT with no code. Unfortunately the icon and tooltip are both particularly unhelpful.
See 2003 WordArt Add-In for 2010-2013 for an example of a Macro-free Add-In that uses Building Blocks Custom Gallery 4 to hold AutoText.
Reply With Quote
  #9  
Old 01-20-2014, 06:27 PM
deepgreen deepgreen is offline Insert identifiers in AutoText snippet. Microsoft word Windows 8 Insert identifiers in AutoText snippet. Microsoft word Office 2013
Novice
Insert identifiers in AutoText snippet. Microsoft word
 
Join Date: Jan 2014
Posts: 8
deepgreen is on a distinguished road
Default

Seems like I am reaching a dead end. If only there was something like this to insert:

{ DATE \@ "yyyyMMddhhmmss" \DONT UPDATE }

It will be the end of my problems!!
Can’t use macros, they require to save docm and security alerts to users.

PD: or any other function like =rand() which generates something useful for this case?

thanks for your help
Reply With Quote
  #10  
Old 01-20-2014, 08:58 PM
Charles Kenyon Charles Kenyon is offline Insert identifiers in AutoText snippet. Microsoft word Windows 7 64bit Insert identifiers in AutoText snippet. Microsoft word Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,165
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've given you my toolbox and have nothing more to offer.
Reply With Quote
  #11  
Old 01-20-2014, 10:39 PM
deepgreen deepgreen is offline Insert identifiers in AutoText snippet. Microsoft word Windows 8 Insert identifiers in AutoText snippet. Microsoft word Office 2013
Novice
Insert identifiers in AutoText snippet. Microsoft word
 
Join Date: Jan 2014
Posts: 8
deepgreen is on a distinguished road
Default

The last thing I found was a sequence. Is it possible to set the sequence to remember the last used number (for example a document variable) ?

I managed to insert a sequence number to the autotext snippet, the numbers were great. Until I delete one number and then they start overlapping.

Any thoughts?
Thanks a lot
Reply With Quote
  #12  
Old 01-21-2014, 06:01 AM
Charles Kenyon Charles Kenyon is offline Insert identifiers in AutoText snippet. Microsoft word Windows 7 64bit Insert identifiers in AutoText snippet. Microsoft word Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,165
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

Sequence will not work.

Like the others, this is a field. If positioned elsewhere in the document, it will change number. If one is inserted or deleted in front of it, it will change number.
Reply With Quote
  #13  
Old 01-21-2014, 09:05 AM
deepgreen deepgreen is offline Insert identifiers in AutoText snippet. Microsoft word Windows 8 Insert identifiers in AutoText snippet. Microsoft word Office 2013
Novice
Insert identifiers in AutoText snippet. Microsoft word
 
Join Date: Jan 2014
Posts: 8
deepgreen is on a distinguished road
Default

Charles,

I just tried every possible thing…. and I think I got a solution. I want to share it with you to know what you think… and if there is any possible downside.

I made a “text form field” which defaults to the current time part of my AutoText snippet. Every time I insert the auto text the time inserted is current. And when I save and reopen the dates are unchanged.

Also you can’t right click and select update. what do you think?

I found some bugs on the approach if you print or export as pdf, the fields are updated. any insights?
I could totally tolerate this scenarios because the documents are not intended for print. Is there any other scenario where the fields will get updated?

Last edited by deepgreen; 01-21-2014 at 11:44 AM.
Reply With Quote
  #14  
Old 01-21-2014, 05:16 PM
Charles Kenyon Charles Kenyon is offline Insert identifiers in AutoText snippet. Microsoft word Windows 7 64bit Insert identifiers in AutoText snippet. Microsoft word Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,165
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

Print preview may do it as well. (Not Print View, Print Preview)

Per your message, you want this topic closed. If so, do not respond.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert identifiers in AutoText snippet. Microsoft word VBA code for Microsoft Word macro — select text and insert footnote ndnd Word VBA 10 01-06-2015 01:47 PM
Insert identifiers in AutoText snippet. Microsoft word How do i insert autotext using a contol toolbox checkbox NP85 Word VBA 12 02-09-2014 03:06 PM
Word 2010 - AutoText Medpack Word 0 12-10-2012 03:26 PM
Using Word autocorrect and autotext entries in outlook dswapp Outlook 2 11-24-2010 10:18 AM
Merge Word 2003 AutoText to Word 2007 damadhatter Word 0 10-15-2009 11:41 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:49 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