Excel to Word Question

H1SOKA

New Member
Joined
Mar 17, 2016
Messages
38
Greetings, Wizards.

I have a somewhat puzzling issue that I'd like help with.

I have a single cell of concatenated data in Sheet1 (A1).

I am trying to figure out how to export this data to Word using a macro. Additionally, the adjacent cell in B1 needs to specify the filename of the document.

Another issue I am having is formatting the text that gets exported from Excel to Word. When I manually copy and paste the data from Excel to Word, a single line break does not appear in Word, even when they have been inserted at the end of the text strings.

In order to visibly separate the lines of text and paragraphs, I am required to manually concatenate TWO =CHAR(10) characters (a line break), at the end of every paragraph.

An example of a concatenated paragraph in my workbook looks like the following, where C2 and D2 contain the cell value =CHAR(10):
Code:
=CONCATENATE(A2,D2,C2,D2)

Although the line breaks are visible in Word, using the =CHAR(10) character also presents problems when exporting to an HTML editor for posting on Wordpress sites. Because =CHAR(10) produces a non-breakable space in HTML, the two line breaks create paragraphs that have two spaces between them, instead of the single break that is seen in Word.

Paragraphs will come out looking like this:

Code:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In molestie ut  arcu fringilla iaculis. Suspendisse quam mauris, sodales id ipsum eget,  iaculis bibendum mauris. 

 

Duis at diam ipsum. Aenean lacus tellus, pulvinar eget elit a, consequat  pretium eros. Suspendisse feugiat, felis at faucibus maximus, risus  erat laoreet turpis, sit amet aliquet nulla libero sit amet felis.

Additionally, the markup of the article itself is broken when pasted into an HTML editor. Instead of the correct paragraph tags being wrapped around the content, HTML treats the =CHAR10 as unbreakable space, leading to the double spacing as seen above.

It seems that I will need to find a way to insert paragraph breaks into the content instead of using a line breaks, accomplished within either Word or Excel. However, I can not find the paragraph break character, nor is there a way that I'm aware of to convert line breaks to paragraph breaks.

Any help in resolving the above will be greatly appreciated. :)
 
Last edited:

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Posting again because I can't edit my post.

I've managed to insert line breaks by wrapping paragraphs tags around the text strings in Excel.

However, it would be best if they did not show up in Word, as I send the Word document to somebody who then uploads the file to Wordpress. The Word document also needs to be edited first before it is sent.
 
Upvote 0
Another update.. so both Word and the HTML correctly recognize the paragraph break IF the text is pasted into Word as 'Text only'. No other special pasting option will format the text correctly.
 
Upvote 0
So why not export the cell contents directly, adding whatever paragraph breaks or line breaks you require to your code instead of to the cells?
 
Upvote 0

Forum statistics

Threads
1,223,805
Messages
6,174,723
Members
452,578
Latest member
Predaking

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top