![]() |
|
|||||||
|
|
|
Thread Tools | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Without knowing how the images are inserted it is something of a guess, but the following will insert the date in the required format after each image.
Code:
Sub Macro1()
'Graham Mayor - http://www.gmayor.com - Last updated - 02 Nov 2017
Dim iShp As Integer
Dim dStartDate As Date
Dim oRng As Range
Dim strDate As String
dStartDate = "01/01/2018"
For iShp = 1 To ActiveDocument.InlineShapes.Count
strDate = Format((dStartDate + iShp), "mmmm d") & _
DateOrdinal(Format((dStartDate + iShp), "d")) & _
Format((dStartDate + iShp), " yyyy")
Set oRng = ActiveDocument.InlineShapes(iShp).Range
oRng.Collapse 0
oRng.Text = vbCr & strDate & vbCr
Set oRng = oRng.Paragraphs(2).Range
oRng.Font.Size = 24
oRng.ParagraphFormat.Alignment = wdAlignParagraphCenter
Next iShp
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 |
|
#2
|
|||
|
|||
|
Thanks, I tried it.
I get an error saying "DateOrdinal" Compile Error: sub or function not defined. I use insert -> pictures to get the images into my document. |
|
#3
|
||||
|
||||
|
Apologies - I forgot to include the dateordinal function. Paul's alternative should work equally well.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
#4
|
|||
|
|||
|
Thanks alot, it works really well. Is it possible to put the dates above the images instead of below?
|
|
|
|
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 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 |