Consulting

Results 1 to 3 of 3

Thread: How to remove trailing CRLF on table picture caption

  1. #1

    How to remove trailing CRLF on table picture caption

    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:
    [VBA]
    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
    [/VBA]

    Thanks in advance for any help.

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Try:
    [VBA]oILS.Range.InsertCaption Label:="Picture", TitleAutoText:="", Title:="", _
    Position:=wdCaptionPositionBelow, ExcludeLabel:=0
    .Cells(1).Range.Characters.Last.Previous.Delete
    .MoveRight wdCell, 1[/VBA]
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •