![]() |
#1
|
|||
|
|||
![]()
A family member is using Word 2016 in Windows 10. I recorded a simple macro for her to insert a date field, a soft return, then a time field, then changing the field to plain text, right-aligning the paragraph, decreasing the point size, and starting a new blank paragraph at left. Works flawlessly in my Word 2010 in W7. In hers, it inserts the dateline, sends it to the right, and then selects that and anything below it. End. The field is still a field (content control, it appears -- could that be the problem?), and the time line never appears.
I have looked through Options for any setting that might be affecting this but can't figure it out. Is there some compatibility problem that won't allow me to successfully record this macro for 2016? I recorded it on my machine, simply because I found it easier that the wretched touchpad on her laptop and related laptop interface problems. Thanks. Last edited by Ulodesk; 04-01-2017 at 04:13 PM. Reason: typos |
#2
|
|||
|
|||
![]()
Is there some reason to not create an AutoText entry with these using CreateDate Fields?
Using Date Fields in Microsoft Word Automated Boilerplate Using Microsoft Word Otherwise, you might do better simply inserting the date and time in a macro rather than inserting a field and then unlinking it. |
#3
|
||||
|
||||
![]()
An autotext as suggested by Charles would do the job, or you could use a simple macro
Code:
Sub InsertDateandTime() Dim orng As Range Set orng = Selection.Range orng.ParagraphFormat.Alignment = wdAlignParagraphLeft orng.Text = Format(Date, "d mmmm yyyy") & vbCr & Format(Time, "hh:mm am/pm") orng.Collapse 0 orng.Select lbl_Exit: Set orng = Nothing Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#4
|
|||
|
|||
![]()
Thank you, gentlemen. I was not aware of the CreateDate field, but I have now used it in a recorded macro in place of the Date field that was turning into a content control in Word 2016. Recording the macro allows me to make the several additional adjustments I mentioned in my original post and run the macro with an [Alt+letter] keystroke.
I'll mark this solved if I can find the item; usually, it is missing. |
#5
|
|||
|
|||
![]()
Glad you got what you need. FYI A keyboard shortcut can also be attached to an AutoText entry.
AutoText advantage: can use in an environment that does not allow macros to run. Will sometimes work where a recorded macro will misfire. AutoText disadvantages: can only be stored in a template, not a document; more difficult to add to the QAT. |
#6
|
||||
|
||||
![]()
FWIW, the AutoText entry could be reduced to a single field coded as:
{CREATEDATE \@ "D MMMM YYYY'↵ 'hh:mm am/pm"} where ↵ is an actual manual line break.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
theUKshrew | Excel Programming | 1 | 02-10-2017 11:16 PM |
![]() |
ptmuldoon | Word | 1 | 12-03-2014 02:28 PM |
![]() |
jg60 | Word | 8 | 06-14-2012 09:51 AM |
Outlook Auto-Reply Rule - Strange behavior | albracco | Outlook | 5 | 09-27-2011 08:18 AM |
![]() |
SatControl | Word | 5 | 02-14-2010 12:57 PM |