PDA

View Full Version : How to remove trailing CRLF on table picture caption



tabletguy
06-24-2012, 11:44 AM
I've read this post on inserting a photo and caption into a table cell:
... forum/showthread.php t=33113 (Modify Macro which Batch Insert Photos to also include caption)

After inserting the caption, it adds a paragraph mark at the end. Inside of a table cell, this causes a new line, which I don't want, since it adds to the height of the cell, and therefore the row.

I cannot figure out how to go to the end of the cell before doing a "backspace". I've been trying for several days. It's a hard item to search for!

I'm using Word 2010

Code:

photoTitle = ": " + photos(nextPhoto, 0) & " <Extra photo details here>"
oILS.Range.InsertCaption Label:="Photo", TitleAutoText:="" _
, Title:=photoTitle, Position:=wdCaptionPositionBelow, ExcludeLabel:=0

Selection.Cells.Item(1).Range.MoveEnd
Selection.Collapse (wdCollapseEnd)
Selection.TypeBackspace


Thanks in advance for any help.

macropod
06-24-2012, 04:47 PM
Try:
oILS.Range.InsertCaption Label:="Picture", TitleAutoText:="", Title:="", _
Position:=wdCaptionPositionBelow, ExcludeLabel:=0
.Cells(1).Range.Characters.Last.Previous.Delete
.MoveRight wdCell, 1

tabletguy
06-25-2012, 08:35 AM
Yes!, that did it (no surprise to you I'm sure).

I'd never seen the "Range.Characters" before.

I assume that ignores the picture that's also in the cell?

Also, of course, I put back the photo title (Title:=photoTitle), in case anyone copies without checking....

** EDIT : I don't see how to mark this as solved. I clicked the top message, but don't see anything.