![]() |
|
#1
|
|||
|
|||
|
Hi,
I'd like to create a document with a date above each image in my document. I want to include each day in 2017 and was wondering if this could be automated somehow. I manually created the first 4 days in the attached screenshot. Any ideas? |
|
#2
|
||||
|
||||
|
This macro will add a date before every inline picture in the active document. Its up to you to put all the images you need in the document before running the macro.
Code:
Sub HotDates()
Dim aDte As Date, aPict As InlineShape, aFld As Field
aDte = #1/1/2017#
CaptionLabels("Figure").NumberStyle = wdCaptionNumberStyleArabic
For Each aPict In ActiveDocument.InlineShapes
aPict.Range.InsertCaption Label:="Figure", Title:=pfun_OrdinalDate(aDte), ExcludeLabel:=True, Position:=wdCaptionPositionAbove
aDte = aDte + 1
Next aPict
For Each aFld In ActiveDocument.Fields
If aFld.Type = wdFieldSequence Then aFld.Delete
Next aFld
End Sub
Public Function pfun_OrdinalDate(dte_toformat As Date) As String
'adapted from http://www.tek-tips.com/faqs.cfm?fid=6742
Dim sOrd As String
Select Case Day(dte_toformat)
Case 1, 21, 31
sOrd = "st "
Case 2, 22
sOrd = "nd "
Case 3, 23
sOrd = "rd "
Case Else
sOrd = "th "
End Select
pfun_OrdinalDate = Format(dte_toformat, "dddd, MMM d") & sOrd & Format(dte_toformat, "yyyy")
End Function
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
#3
|
|||
|
|||
|
Thanks this is perfect.
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Help needed: How can I insert regular interval dates in excel row
|
joneill | Excel | 5 | 11-24-2014 10:25 AM |
| Insert an image to a document created by a userform? | jgoodrich | Word VBA | 0 | 10-22-2014 11:03 AM |
Insert image based on document custom property
|
anandyrh | Word | 1 | 08-14-2013 12:08 AM |
automatically insert an image into a document
|
hanrattyc | Word | 1 | 05-13-2013 04:27 PM |
| Background image vs. insert image | lilaria | PowerPoint | 0 | 04-18-2011 08:45 AM |