PDA

View Full Version : Very strange behaviour of paste special



saban
11-10-2006, 08:47 AM
Does anyone knows why when I use paste special and select unformatted text word pastes some additional text which is not shown in document and is not hidden text(you cannot toggle between hidden to se it)

Very strange

mdmackillop
11-10-2006, 05:46 PM
Hi Saban,
As this is VBA forum, can you confirm that you are talking about programming problems. If this is simply (:whistle:) a Word problem, what does MS say?
Regards
MD

fumei
11-11-2006, 06:56 PM
Good answer.

TonyJollans
11-13-2006, 07:44 AM
The forum is called Word Help - it doesn't say anything about VBA only. I'll grant the site is called VBAExpress but I didn't realise non-VBA questions and/or answers were not welcome.

saban - I'm afraid I don't understand what you are saying - how do you know that there is additional text pasted if it's not shown in the document?

fumei
11-13-2006, 06:21 PM
Ah...Tony, you are correct of course...

saban
11-16-2006, 06:54 AM
Then explain me this I have 2 paragraphs numbered 2 and 3 :
example:
(2) Dans le cadre de son action politique, l'Union devrait viser ? emp?cher toute violation du principe du respect de la dignit? humaine.
Il y a lieu de pr?voir, ? l'?chelle de l'Union europ?enne, des mesures l?gislatives relatives ? la protection de l'?panouissement physique, mental et moral des mineurs, en lia


ison avec les contenus de l'ensemble des services audiovisuels et d'information, en prenant des dispositions contre la circulation de contenus illicites et en emp?chant aux mineurs l'acc?s aux ?missions ou aux services destin?s aux adultes.






(3) Il y a lieu de pr?voir, ? l'?chelle de l'Union, des mesures l?gislatives relatives ? la protection de l'?panouissement physique, mental et moral des mineurs, en liaison avec les contenus de

And between them is just emptiness but as you can see I pasted it here and ofcourse it paste it as unformatted text and you can see what is now in between
???

saban
11-16-2006, 06:57 AM
Anyhow does anyone knows how can I select whole line with VBA
Like if you click on beggining of each line and whole line is selected-any ideas how to do that because if i try to record a macro mouse does not work and I cannot find keyboard command to select whole line

fumei
11-16-2006, 07:27 AM
Say what? What does the line question have to do with the paste question?

If the paragraphs had used a line feed only (using Shift-Enter) between the paragraphs then you would get that kind of numbering.

As for using VBA to make the selection the whole line....look in Help. It took me three seconds to find the answer in Help. I knew the answer, but I wanted to see how difficult it was to find it in Help. Help works and is your friend.

saban
11-16-2006, 09:27 AM
the problem is when I select entire text and copy it and then paste it as unformatted text the additional text appears between paragraphs and i dont know why

And the solution I have found is to copy each line separately and paste it as unformated text

fumei
11-16-2006, 07:31 PM
Shrug. I guess we will never find out what the "additional text" was.

Glad something worked for you.

saban
11-17-2006, 02:01 AM
Could you please open this file ozgrid.doc
select all and paste it as unformatted text in new document and you will see what I a talking about

Thnx
Saban

mdmackillop
11-17-2006, 04:46 AM
Hi Saban,
If you open the file in notepad you will see the additional text. I guess this was deleted or changed but minor file corruption is causing the problem.
Regards
MD

fumei
11-17-2006, 08:03 AM
Well...thanks for posting the file. I have never seen anything like it. It is indeed very very strange. I did some looking. Here is the text again.

(2) Dans le cadre de son action politique, l'Union devrait viser ? emp?cher toute violation du principe du respect de la dignit? humaine.
Il y a lieu de pr?voir, ? l'?chelle de l'Union europ?enne, des mesures l?gislatives relatives ? la protection de l'?panouissement physique, mental et moral des mineurs, en liaison avec les contenus de l'ensemble des services audiovisuels et d'information, en prenant des dispositions contre la circulation de contenus illicites et en emp?chant aux mineurs l'acc?s aux ?missions ou aux services destin?s aux adultes.
(3) Il y a lieu de pr?voir, ? l'?chelle de l'Union, des mesures l?gislatives relatives ? la protection de l'?panouissement physique, mental et moral des mineurs,

Now between "destin?s aux adultes." and "(3)" is a paragraph mark.

Using the code:MsgBox Selection.Textto display the contents of the Selection, here is what I found.

If you select ONLY the paragraph mark (NOTHING else), Selection.Text returns:

Il y a lieu de pr?voir, ? l'?chelle de l'Union europ?enne, des mesures l?gislatives relatives ? la protection de l'?panouissement physique, mental et moral des mineurs, en liaison avec les contenus de l'ensemble des services audiovisuels et d'information, en prenant des dispositions contre la circulation de contenus illicites et en emp?chant aux mineurs l'acc?s aux ?missions ou aux services destin?s aux adultes.

Plus the two ASCII characters of the paragraph mark.

Somehow - and I really really don't know how - the paragraph mark ITSELF contains that "additional text". Somehow, that text is hidden inside the paragraph mark.

How did you DO that?????????

Not only that, but if you select the paragraph mark, and the next character - this is with it Keep Source Formatting, or Match Destination Formatting, so the "additional text" is NOT showing...so the paragraph mark and the "(" is selected, the following code:MsgBox Selection.Text & _
vbCrLf & Selection.Start & _
vbCrLf & Selection.Endshow the entire "hidden" or additional text, the the Long positions of Start and End.

The Selection Start and End are 419 characters different. So, Word is seeing the Range of the Selection - even though it is only two characters - as equal to 419 characters.

VERY strange. I have no idea how that happened. So yes, I would have to agree with Malcolm, this file is corrupted in some manner. I would suggest you determine all the text that is appropriate, and make a new file. This one is very strange.

Frankly, there is nothing that I know of in the Object model that permits a paragraph mark to hold hidden text inside it. Yet there it is, I can see it myself.

VERY strange.

More: put the cursor somewhere on the first line of (3). use the left arrow key. The cursor moves to the left. Hold it down, and the cursor moves to the left character by character. Fine, this is what it is supposed to do. BUT, when it reaches the "(" of "(3)" - still holding the left arrow key moving the cursor - it disappears. It somehow goes into a black hole. It never comes out. No matter how long you hold the arrow key, it never continues.

The same going the other way. You can NOT move the cursor one character from the paragraph mark at the end of (2). Not with the keyboard. You can of course move it with the mouse, but you can NOT move it sequentially. It goes into this very bizarre black hole.

I have never seen anything like it.

fumei
11-17-2006, 08:08 AM
I notice that if you open the file with WordPad, there is this funny textbox thing between the paragraphs. A dotted box, like a text box. There is no text in it - I can not see the "additional text". You can enter text into this box.

Yup...strange.

fumei
11-17-2006, 08:10 AM
Bottom line? It is not Paste Special that is the issue. This file is corrupt in some way. Although I have no idea why...or even how.

TonyJollans
11-19-2006, 02:22 AM
It does look like corruption.

There is a table hidden in there with what appears to be zero width. I moved the cursor back from the beginning of the paragraph numbered (3) and was investigating when Word (2003) fell over and said it was searching for a solution - it came back with a recovered document and the table visible.

saban
11-20-2006, 01:29 AM
i told you guys it is very strange and i did not do that I received document like that i will ask the person who sent it what did he do

But i guess It has something to do with paragraphs and empty spaces between them

But if I copy each paragraph separately then it is OK (so I guess it is something between these empty spaces between)

saban
11-20-2006, 01:40 AM
Is it possible to delete somehow just empty spaces between paragraphs or maybe tables that are zerow width that are within this empty spaces

fumei
11-20-2006, 08:25 AM
Tony, you absolutely correct. I never thought of a zero width table. I ran a check for tables, and got a return of 1. There IS a table.

So I ran code to make the width 50%. Word crashed, and the recovered document had the table there (with that "additional text"), at 50%.

Saban, there is no empty space. There is a zero width table there. HOW it got there, I don't know. But there it is.

If this text is not relevant, you can delete the table easy enough.

saban
11-21-2006, 02:51 AM
How can I delete the zero width table if it is not visible

fumei
11-21-2006, 03:36 AM
ActiveDocument.Tables(1).Delete

At least in the the file you posted, it is Tables(1). If you have legitimate tables in a larger document, then you will have to use the appropriate index number.

saban
11-21-2006, 03:43 AM
Yes the problem is these are long documents and valid tables are also in it is it possible to delete just tables with zero width

mdmackillop
11-21-2006, 05:48 AM
Here's a start
Dim t As Table
For Each t In ActiveDocument.Tables
MsgBox t.PreferredWidth
Next

saban
11-21-2006, 06:29 AM
Thnx