Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-03-2017, 10:54 PM
macropod's Avatar
macropod macropod is offline Need help creating a document with 365 images, with a day of the year 2018 captioned on each image. Windows 7 64bit Need help creating a document with 365 images, with a day of the year 2018 captioned on each image. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,521
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Here's a slightly different approach that centres the pics horizontally, adds the date to the next line of the same paragraph, and superscripts the ordinals.


Code:
Sub AddPicDatesBelow()
Application.ScreenUpdating = False
Dim iShp As Long, dStartDate As Date, oRng As Range, strOrd As String
dStartDate = CDate("01/01/2018") - 1
With ActiveDocument
  For iShp = 1 To .InlineShapes.Count
    dStartDate = dStartDate + 1
    strOrd = DateOrdinal(Format((dStartDate), "d"))
    Set oRng = .InlineShapes(iShp).Range
    With oRng
      .ParagraphFormat.Alignment = wdAlignParagraphCenter
      .Collapse wdCollapseEnd
      .Text = Chr(11) & Format((dStartDate), "mmmm d") & strOrd & Format((dStartDate), " yyyy") & vbCr
      .Start = .Start + 1
      .Font.Size = 24
      .Start = .Start + InStr(.Text, strOrd) - 1
      .End = .Start + 2
      .Font.Superscript = True
    End With
  Next iShp
End With
Set oRng = Nothing
Application.ScreenUpdating = True
End Sub

Function DateOrdinal(Val As Long) As String
Dim strOrd As String
If (Val Mod 100) < 11 Or (Val Mod 100) > 13 Then strOrd = Choose(Val Mod 10, "st", "nd", "rd") & ""
DateOrdinal = IIf(strOrd = "", "th", strOrd)
End Function
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to search for a specific year from a table with year range? Wii Excel 0 05-05-2015 12:40 PM
How to calculate a rolling year-to-date percentage by quarter as the year progresses sleake Excel Programming 2 04-23-2015 11:51 AM
Need help creating a document with 365 images, with a day of the year 2018 captioned on each image. Need advice on creating new .pst files every year Rockitman31 Outlook 1 03-02-2013 08:00 AM
Creative Ways for a year-to-year comparison??? ridonkulous5 Excel 1 03-23-2011 04:49 PM
Referencing a Captioned Picture ComcoDG Word 0 11-10-2008 04:40 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:05 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft