![]() |
#1
|
|||
|
|||
![]()
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:
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. |
#2
|
|||
|
|||
![]()
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 |
#3
|
|||
|
|||
![]()
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! |
#4
|
|||
|
|||
![]()
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. |
#5
|
|||
|
|||
![]()
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. |
#6
|
|||
|
|||
![]() Quote:
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:
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 |
#7
|
|||
|
|||
![]()
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! |
#8
|
|||
|
|||
![]()
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. |
#9
|
|||
|
|||
![]()
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 |
#10
|
|||
|
|||
![]()
I've given you my toolbox and have nothing more to offer.
|
#11
|
|||
|
|||
![]()
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 |
#12
|
|||
|
|||
![]()
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. |
#13
|
|||
|
|||
![]()
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. |
#14
|
|||
|
|||
![]()
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. |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
ndnd | Word VBA | 10 | 01-06-2015 01:47 PM |
![]() |
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 |