View Single Post
 
Old 11-22-2016, 01:42 AM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,158
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote