Hello,
I used "PasteAndFormat (wdFormatOriginalFormatting)" to insert text from Excel cells in a Word document and keeping the format.
It works but, each time the code inserts something, it seams to add a "carriage return". In fact, after each insertion it goes back to a new line.
How could I avoid that?
(I already tried to use "Contains.SetText finaltext / Contains.PutInClipboard", it works, with no carriage return, but I loose the format)
Thank you in advance,
THC
I used "PasteAndFormat (wdFormatOriginalFormatting)" to insert text from Excel cells in a Word document and keeping the format.
It works but, each time the code inserts something, it seams to add a "carriage return". In fact, after each insertion it goes back to a new line.
How could I avoid that?
VBA Code:
Sub Insert_at_Bookmark(BookmarkName As String, wdDoc As Word.Document)
Dim wdbmRange As Word.Range
Dim textrange As String
Dim finaltext As String
Dim Contains As New MSForms.DataObject
Set wdbmRange = wdDoc.Bookmarks(BookmarkName).Range
textrange = Range(BookmarkName)
finaltext = Range(textrange)
Range(textrange).Copy
With wdbmRange
.Select
.PasteAndFormat (wdFormatOriginalFormatting)
.Select
End With
Set wdbmRange = Nothing
textrange = ""
finaltext = ""
End Sub
(I already tried to use "Contains.SetText finaltext / Contains.PutInClipboard", it works, with no carriage return, but I loose the format)
Thank you in advance,
THC