Missing spaces between text and images when pasting HTML to Word


G

gfox

Hello,

I've got a problem when copying content from a HTML page and pasting it as
HTML in my Word document.
Word simply removes the spaces between the text and images.

Steps to reproduce:

1. create a simple HTML page with the following content:

<img src="http://www.t-chest.co.uk/2005/images/whatever-happy-bunny.gif">
where is the space between the image and this text?

2. launch this page in IE, select the image and text, then paste it as HTML
in Word

You'll notice that the space between the image and the text has
disapeared... I'm using Word 2007, but I've had this issue reported under
Word 2003 and 2000 as well, so i think it affects all versions.

Do you have any idea why Word is behaving like this? Any workaround?

------------

I've been using the following workaround so far: it consists in looking for
all the graphics that have just been pasted and adding a space after them. To
do this, i've written the following macro:

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^g" ' Find graphics
.Replacement.Text = "^& " ' Replace the found graphics by itself plus an
empty space
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll

But.... this workaround raises a new issue with pasted images that are
larger than the page... When this macro is executed and a space is added
after this image, the text "Error!" gets inserted right before the graphic...
I can't even delete this text, or it'll remove the graphics with it.

Any help would be welcomed:)
 
Ad

Advertisements

R

Robert M. Franz [RMF]

Hello gfox
I've got a problem when copying content from a HTML page and pasting it as
HTML in my Word document.
Word simply removes the spaces between the text and images.

Steps to reproduce:

1. create a simple HTML page with the following content:

<img src="http://www.t-chest.co.uk/2005/images/whatever-happy-bunny.gif">
where is the space between the image and this text?

you could've put the whole page up there, not only the picture ... :)

2. launch this page in IE, select the image and text, then paste it as HTML
in Word

You'll notice that the space between the image and the text has
disapeared... I'm using Word 2007, but I've had this issue reported under
Word 2003 and 2000 as well, so i think it affects all versions.

Do you have any idea why Word is behaving like this? Any workaround?

Have you tried opening the page in Word directly: File | Open (well,
through the Office button, but you know what I mean) and insert the URL
to the document directly?

HTH
Robert
 
G

gfox

Hi Robert,

If you want the whole web page, it's simple: here it is...

<html>
<body>

<img src="http://csscreator.com/files/headerbg.jpg"> where is the space
between the image and this text?


</body>
</html>

Now you are right, when i open the web page in Word directly, the space
between the images and text has gone. Not very nice. Any idea why?
 
R

Robert M. Franz [RMF]

gfox said:
If you want the whole web page, it's simple: here it is...

<html>
<body>

<img src="http://csscreator.com/files/headerbg.jpg"> where is the space
between the image and this text?


</body>
</html>

Now you are right, when i open the web page in Word directly, the space
between the images and text has gone. Not very nice. Any idea why?

I'm not quite sure I understand your description: nowhere in the HTML
code is there any "spacing" (or: empty line, etc.) defined between the
image and the text.

IE does show me a slightly larger vertical gap than Word, maybe by 1.5
mm. But there's nothing inherent in the code that would suggest more (or
less), so any representation is as good as another ...

HTH
Robert
 
G

gfox

Hi Robert,

I don't see the use of your reply.

In the HTML code, there IS a space character between the image tag and the
text. Any browser renders the HTML as an image, followed by a space, followed
by the text (how surprising!). I don't see how you can defend Word's
behaviour on this point...

Anyway, I've posted my issue on another forum and some nice people were able
to provide me with a working workaround. If anyone is interested in viewing
this workaround, he can check this link:
http://www.wopr.com/index.php?showtopic=766109&st=0&gopid=790937&#entry790937

Basically, you can run this macro after copy/pasting HTML code in Word:

Selection.HomeKey Unit:=wdStory
With Selection.Find
.ClearFormatting
.Text = "^g" ' Find graphics
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Do While .Execute
Selection.MoveRight Unit:=wdCharacter
Selection.TypeText " "
Loop
End With
 
R

Robert M. Franz [RMF]

gfox said:
I don't see the use of your reply.

In the HTML code, there IS a space character between the image tag and the
text. Any browser renders the HTML as an image, followed by a space, followed
by the text (how surprising!). I don't see how you can defend Word's
behaviour on this point...

I created an HTML file directly from your code, with nothing else in it.
When I open this in Mozilla 3.5.2 and IE 8 I get a greyish image
spanning the whole width and the text _below_ the image. Hence, any
white space between the two elements is moot in my views.

Word shows the very same, maybe with slightly smaller vertical gap. So I
assumed you had an issue with this gap, and that's the issue I was
answering.

Glad your problem has been sorted out in the mean time.

Greetinx
Robert
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top