A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

A Bug I Think in Word 2000



 
 
Thread Tools Display Modes
  #1  
Old February 3rd, 2006, 06:52 PM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default A Bug I Think in Word 2000

Enter a simple table and add a bit of text to a few cells.

Put a check in: ToolOptionsEditUse smart cut and paste

Type a few words after the table and copy it to the clipboard.

Now run:

Sub Test()
Dim tbl As Word.Table
Dim cel As Word.Cell
Dim rng As Word.Range
Set tbl = ActiveDocument.Tables(1)
For Each cel In tbl.Range.Cells
Set rng = cel.Range
rng.MoveEnd wdCharacter, -1
rng.Collapse wdCollapseEnd
rng.Paste
Next
End Sub


This has interesting results.
1. If you selected and copied a complete word or phrase (without the
leading space). The result is the text is pasted to all cells as
expected, but a run time error is generated.

Run Time Error '5825' Object has been deleted. :-(

2. If you copied only part of a word or a word/phase including a
leading
space, all is well.

I have discovered that the cause of this behaviour is
ToolsOptionsEditUse smart cut and paste. With that option off, the
procedure works as expected with no run time error. That is the cause,
but I don't really understand the why.

I suppose that knowing this you could use an error handler:

Sub Test()
Dim tbl As Word.Table
Dim cel As Word.Cell
Dim rng As Word.Range
Set tbl = ActiveDocument.Tables(1)
On Error GoTo Handler
For Each cel In tbl.Range.Cells
Set rng = cel.Range
rng.MoveEnd wdCharacter, -1
rng.Collapse wdCollapseEnd
rng.Paste
Next
Exit Sub
Handler:
End Sub

Does anyone know if this bug, as I have called it, is documented, why
it happends, or a more appropriate workaround?

Thanks.

  #2  
Old February 3rd, 2006, 10:54 PM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default A Bug I Think in Word 2000

Must be something more to it, Greg. I tried it exactly as you describe and
can't create the problem. What are your Smart cut and paste settings?



"Greg" wrote in message
oups.com...
Enter a simple table and add a bit of text to a few cells.

Put a check in: ToolOptionsEditUse smart cut and paste

Type a few words after the table and copy it to the clipboard.

Now run:

Sub Test()
Dim tbl As Word.Table
Dim cel As Word.Cell
Dim rng As Word.Range
Set tbl = ActiveDocument.Tables(1)
For Each cel In tbl.Range.Cells
Set rng = cel.Range
rng.MoveEnd wdCharacter, -1
rng.Collapse wdCollapseEnd
rng.Paste
Next
End Sub


This has interesting results.
1. If you selected and copied a complete word or phrase (without the
leading space). The result is the text is pasted to all cells as
expected, but a run time error is generated.

Run Time Error '5825' Object has been deleted. :-(

2. If you copied only part of a word or a word/phase including a
leading
space, all is well.

I have discovered that the cause of this behaviour is
ToolsOptionsEditUse smart cut and paste. With that option off, the
procedure works as expected with no run time error. That is the cause,
but I don't really understand the why.

I suppose that knowing this you could use an error handler:

Sub Test()
Dim tbl As Word.Table
Dim cel As Word.Cell
Dim rng As Word.Range
Set tbl = ActiveDocument.Tables(1)
On Error GoTo Handler
For Each cel In tbl.Range.Cells
Set rng = cel.Range
rng.MoveEnd wdCharacter, -1
rng.Collapse wdCollapseEnd
rng.Paste
Next
Exit Sub
Handler:
End Sub

Does anyone know if this bug, as I have called it, is documented, why
it happends, or a more appropriate workaround?

Thanks.



  #3  
Old February 3rd, 2006, 11:22 PM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default A Bug I Think in Word 2000

Jezebel,

I don't know if you noticed the complete subject, but the error only occurs
in Word2000(well I don't know about Word97, or 2002). It doesn't occur in
Word2003.

When ToolsOptionEditSmart cut and paste is checked the error occurs if I
select and copy a complete word or phrase to the clipboard. It doesn't
occur if I select and copy the middle part of a word, the tail end of a
word, or a complete word including a leading space.

If ToolsOptionsEditSmart cut and paste is uncheck, then the error doesn't
occur.

I have only tested on my Word2000 machine at work, so the problem could be
isolated to that machine.

Cheers.


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

"Jezebel" wrote in message
...
Must be something more to it, Greg. I tried it exactly as you describe and
can't create the problem. What are your Smart cut and paste settings?



"Greg" wrote in message
oups.com...
Enter a simple table and add a bit of text to a few cells.

Put a check in: ToolOptionsEditUse smart cut and paste

Type a few words after the table and copy it to the clipboard.

Now run:

Sub Test()
Dim tbl As Word.Table
Dim cel As Word.Cell
Dim rng As Word.Range
Set tbl = ActiveDocument.Tables(1)
For Each cel In tbl.Range.Cells
Set rng = cel.Range
rng.MoveEnd wdCharacter, -1
rng.Collapse wdCollapseEnd
rng.Paste
Next
End Sub


This has interesting results.
1. If you selected and copied a complete word or phrase (without the
leading space). The result is the text is pasted to all cells as
expected, but a run time error is generated.

Run Time Error '5825' Object has been deleted. :-(

2. If you copied only part of a word or a word/phase including a
leading
space, all is well.

I have discovered that the cause of this behaviour is
ToolsOptionsEditUse smart cut and paste. With that option off, the
procedure works as expected with no run time error. That is the cause,
but I don't really understand the why.

I suppose that knowing this you could use an error handler:

Sub Test()
Dim tbl As Word.Table
Dim cel As Word.Cell
Dim rng As Word.Range
Set tbl = ActiveDocument.Tables(1)
On Error GoTo Handler
For Each cel In tbl.Range.Cells
Set rng = cel.Range
rng.MoveEnd wdCharacter, -1
rng.Collapse wdCollapseEnd
rng.Paste
Next
Exit Sub
Handler:
End Sub

Does anyone know if this bug, as I have called it, is documented, why
it happends, or a more appropriate workaround?

Thanks.





  #4  
Old February 3rd, 2006, 11:30 PM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default A Bug I Think in Word 2000

You're right, I didn't notice that. As for a workaround: perhaps instead of
collapsing the cell range and pasting, try using Range.InsertAfter ?





"Greg Maxey" wrote in message
...
Jezebel,

I don't know if you noticed the complete subject, but the error only
occurs in Word2000(well I don't know about Word97, or 2002). It doesn't
occur in Word2003.

When ToolsOptionEditSmart cut and paste is checked the error occurs if
I select and copy a complete word or phrase to the clipboard. It doesn't
occur if I select and copy the middle part of a word, the tail end of a
word, or a complete word including a leading space.

If ToolsOptionsEditSmart cut and paste is uncheck, then the error
doesn't occur.

I have only tested on my Word2000 machine at work, so the problem could be
isolated to that machine.

Cheers.


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

"Jezebel" wrote in message
...
Must be something more to it, Greg. I tried it exactly as you describe
and can't create the problem. What are your Smart cut and paste settings?



"Greg" wrote in message
oups.com...
Enter a simple table and add a bit of text to a few cells.

Put a check in: ToolOptionsEditUse smart cut and paste

Type a few words after the table and copy it to the clipboard.

Now run:

Sub Test()
Dim tbl As Word.Table
Dim cel As Word.Cell
Dim rng As Word.Range
Set tbl = ActiveDocument.Tables(1)
For Each cel In tbl.Range.Cells
Set rng = cel.Range
rng.MoveEnd wdCharacter, -1
rng.Collapse wdCollapseEnd
rng.Paste
Next
End Sub


This has interesting results.
1. If you selected and copied a complete word or phrase (without the
leading space). The result is the text is pasted to all cells as
expected, but a run time error is generated.

Run Time Error '5825' Object has been deleted. :-(

2. If you copied only part of a word or a word/phase including a
leading
space, all is well.

I have discovered that the cause of this behaviour is
ToolsOptionsEditUse smart cut and paste. With that option off, the
procedure works as expected with no run time error. That is the cause,
but I don't really understand the why.

I suppose that knowing this you could use an error handler:

Sub Test()
Dim tbl As Word.Table
Dim cel As Word.Cell
Dim rng As Word.Range
Set tbl = ActiveDocument.Tables(1)
On Error GoTo Handler
For Each cel In tbl.Range.Cells
Set rng = cel.Range
rng.MoveEnd wdCharacter, -1
rng.Collapse wdCollapseEnd
rng.Paste
Next
Exit Sub
Handler:
End Sub

Does anyone know if this bug, as I have called it, is documented, why
it happends, or a more appropriate workaround?

Thanks.







  #5  
Old February 3rd, 2006, 11:55 PM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default A Bug I Think in Word 2000

Good idea. I will try that Monday when I am back at that machine.

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Jezebel wrote:
You're right, I didn't notice that. As for a workaround: perhaps
instead of collapsing the cell range and pasting, try using
Range.InsertAfter ?




"Greg Maxey" wrote in message
...
Jezebel,

I don't know if you noticed the complete subject, but the error only
occurs in Word2000(well I don't know about Word97, or 2002). It
doesn't occur in Word2003.

When ToolsOptionEditSmart cut and paste is checked the error
occurs if I select and copy a complete word or phrase to the
clipboard. It doesn't occur if I select and copy the middle part of
a word, the tail end of a word, or a complete word including a
leading space. If ToolsOptionsEditSmart cut and paste is uncheck, then
the error
doesn't occur.

I have only tested on my Word2000 machine at work, so the problem
could be isolated to that machine.

Cheers.


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

"Jezebel" wrote in message
...
Must be something more to it, Greg. I tried it exactly as you
describe and can't create the problem. What are your Smart cut and
paste settings? "Greg" wrote in message
oups.com...
Enter a simple table and add a bit of text to a few cells.

Put a check in: ToolOptionsEditUse smart cut and paste

Type a few words after the table and copy it to the clipboard.

Now run:

Sub Test()
Dim tbl As Word.Table
Dim cel As Word.Cell
Dim rng As Word.Range
Set tbl = ActiveDocument.Tables(1)
For Each cel In tbl.Range.Cells
Set rng = cel.Range
rng.MoveEnd wdCharacter, -1
rng.Collapse wdCollapseEnd
rng.Paste
Next
End Sub


This has interesting results.
1. If you selected and copied a complete word or phrase (without
the leading space). The result is the text is pasted to all cells
as expected, but a run time error is generated.

Run Time Error '5825' Object has been deleted. :-(

2. If you copied only part of a word or a word/phase including a
leading
space, all is well.

I have discovered that the cause of this behaviour is
ToolsOptionsEditUse smart cut and paste. With that option off,
the procedure works as expected with no run time error. That is
the cause, but I don't really understand the why.

I suppose that knowing this you could use an error handler:

Sub Test()
Dim tbl As Word.Table
Dim cel As Word.Cell
Dim rng As Word.Range
Set tbl = ActiveDocument.Tables(1)
On Error GoTo Handler
For Each cel In tbl.Range.Cells
Set rng = cel.Range
rng.MoveEnd wdCharacter, -1
rng.Collapse wdCollapseEnd
rng.Paste
Next
Exit Sub
Handler:
End Sub

Does anyone know if this bug, as I have called it, is documented,
why it happends, or a more appropriate workaround?

Thanks.



  #6  
Old February 4th, 2006, 12:07 AM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default A Bug I Think in Word 2000

Jezebel,

I forgot, I already tried that and it works fine:

Sub Test3()
Dim MyData As DataObject
Dim myString As String
Dim tbl As Word.Table
Dim cel As Word.Cell
Dim rng As Word.Range

Set MyData = New DataObject
MyData.GetFromClipboard
myString = MyData.GetText
Set tbl = ActiveDocument.Tables(1)
For Each cel In tbl.Range.Cells
Set rng = cel.Range
rng.MoveEnd wdCharacter, -1
rng.InsertAfter myString
Next
End Sub



Any thoughts on why it happens? I mean I know it happens because smart cut
and paste is enabled, but why do you suppose that is?


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Jezebel wrote:
You're right, I didn't notice that. As for a workaround: perhaps
instead of collapsing the cell range and pasting, try using
Range.InsertAfter ?




"Greg Maxey" wrote in message
...
Jezebel,

I don't know if you noticed the complete subject, but the error only
occurs in Word2000(well I don't know about Word97, or 2002). It
doesn't occur in Word2003.

When ToolsOptionEditSmart cut and paste is checked the error
occurs if I select and copy a complete word or phrase to the
clipboard. It doesn't occur if I select and copy the middle part of
a word, the tail end of a word, or a complete word including a
leading space. If ToolsOptionsEditSmart cut and paste is uncheck, then
the error
doesn't occur.

I have only tested on my Word2000 machine at work, so the problem
could be isolated to that machine.

Cheers.


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

"Jezebel" wrote in message
...
Must be something more to it, Greg. I tried it exactly as you
describe and can't create the problem. What are your Smart cut and
paste settings? "Greg" wrote in message
oups.com...
Enter a simple table and add a bit of text to a few cells.

Put a check in: ToolOptionsEditUse smart cut and paste

Type a few words after the table and copy it to the clipboard.

Now run:

Sub Test()
Dim tbl As Word.Table
Dim cel As Word.Cell
Dim rng As Word.Range
Set tbl = ActiveDocument.Tables(1)
For Each cel In tbl.Range.Cells
Set rng = cel.Range
rng.MoveEnd wdCharacter, -1
rng.Collapse wdCollapseEnd
rng.Paste
Next
End Sub


This has interesting results.
1. If you selected and copied a complete word or phrase (without
the leading space). The result is the text is pasted to all cells
as expected, but a run time error is generated.

Run Time Error '5825' Object has been deleted. :-(

2. If you copied only part of a word or a word/phase including a
leading
space, all is well.

I have discovered that the cause of this behaviour is
ToolsOptionsEditUse smart cut and paste. With that option off,
the procedure works as expected with no run time error. That is
the cause, but I don't really understand the why.

I suppose that knowing this you could use an error handler:

Sub Test()
Dim tbl As Word.Table
Dim cel As Word.Cell
Dim rng As Word.Range
Set tbl = ActiveDocument.Tables(1)
On Error GoTo Handler
For Each cel In tbl.Range.Cells
Set rng = cel.Range
rng.MoveEnd wdCharacter, -1
rng.Collapse wdCollapseEnd
rng.Paste
Next
Exit Sub
Handler:
End Sub

Does anyone know if this bug, as I have called it, is documented,
why it happends, or a more appropriate workaround?

Thanks.



  #7  
Old February 4th, 2006, 12:37 AM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default A Bug I Think in Word 2000


Any thoughts on why it happens? I mean I know it happens because smart
cut and paste is enabled, but why do you suppose that is?


Are you able to identify the line that throws the error?

To hazard a guess as to cause: from your account, all cells are actually
processed, so the error comes at the end of the loop. Perhaps the smart
cut-and-paste, in trying to deal with the superfluous space, is shifting an
internal range pointer, so that on the final iteration it thinks there is
another cell to process, then throws the error when it finds there isn't
one.


  #8  
Old February 4th, 2006, 12:44 AM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default A Bug I Think in Word 2000

I think you are right. I just didn't know how to put it in technical lingo.

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Jezebel wrote:
Any thoughts on why it happens? I mean I know it happens because
smart cut and paste is enabled, but why do you suppose that is?


Are you able to identify the line that throws the error?

To hazard a guess as to cause: from your account, all cells are
actually processed, so the error comes at the end of the loop.
Perhaps the smart cut-and-paste, in trying to deal with the
superfluous space, is shifting an internal range pointer, so that on
the final iteration it thinks there is another cell to process, then
throws the error when it finds there isn't one.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
hard space between words. Sandy L General Discussion 7 May 5th, 2006 08:25 PM
Word 97 in Windows XP to maintain formatting Charlie''s Word VBA questions General Discussion 21 October 24th, 2005 09:49 PM
How do I get rid of page numbers. The page number virus flamestar General Discussion 3 August 19th, 2005 02:31 AM
How to change merge forms from Word Perfect to Microsoft Word Charles Kenyon General Discussion 1 December 30th, 2004 04:35 PM
Word 2000 DDE Speed Stefan German General Discussion 0 May 17th, 2004 04:14 PM


All times are GMT +1. The time now is 02:30 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.