*Another* MoveDown bug in Word?

N

Nick Maddern

Hi,

I think I have come across another MoveDown/MoveUp bug in word. To begin
with, I have tested this with
- Windows 2000 Professional (No service packs and SP-4)
- Word 2000 (No service packs and SP-3)
- Screen resolutions of (1024x768) and (1280x1024)

Under particular circumstances, the MoveDown/MoveUp method will not work at
all, and no error is produced (unlike the known bug 235876)

To make this happen you first need to start Word, and exit it with the word
window in the following state:

- The Word window height less than 1/2 the height of the vertical screen
resolution
- The bottom of the Word window must be in the lower 1/2 of the screen

Next, start word and close all open documents. Then run a macro which does
the following
- Minimizes word &
- Then utilizes MoveUp/MoveDown

NOTE: The bug will not manifest itself if
- There is already a document open
- Or the application window is visible on the screen.

I have written a macro which should reproduce the problem. What will happen
is:

- Bug NOT exhibited: There will be 9 empty/blank lines in the document
- Bug IS exhibited: There will be 9 lines containing the text Line[1-9]

To stop the bug from exhibiting, you must start & then exit word with in the
following state:

- The word window height more than 1/2 the height of the vertical screen
resolution.

NOTE: Maximizing the window does NOT affect the window height. The window
must be in 'Restore Down' mode

Then restart word and run the macro. The bug should not be produced

'------ START HERE ------
Sub RunIt()
' Close all the documents
If (Documents.Count > 0) Then
Call Application.Documents.Close(wdDoNotSaveChanges)
End If

' Minimize the application window
Let Application.WindowState = wdWindowStateMinimize

' Create a new document
Call Documents.Add.Activate

' Insert some text
Dim i As Integer
For i = 1 To 9
Call Selection.InsertAfter("Line" & i & vbCrLf)
Next i
Call Selection.InsertAfter("Line" & i + 1)

' Go to the last line
Call Selection.GoTo(wdGoToLine, wdGoToLast)

' Start deleting text
For i = 1 To 10
Call Selection.MoveRight(wdWord, 1, wdExtend)
Call Selection.Range.Delete
Call Selection.MoveUp(wdLine, 1, wdMove)
Next

' Restore the window
Let Application.WindowState = wdWindowStateMaximize

' Goto the first line (i.e. scroll up)
Call Selection.GoTo(wdLine, wdFirst)
End Sub
'------ END HERE ------

I would be very interested to hear if other people can reproduce this.

Thanks, Nick

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/com...9136c67c&dg=microsoft.public.word.vba.general
 
T

Tony Jollans

I don't get quite the same as you say, but certainly not correct results.

I suspect that working with the selection (a property of the window) when
you haven't got a proper window is the reason. Putting
Application.ScreenRefresh between adding and deleting the lines sorts it
out.

--
Enjoy,
Tony


Nick Maddern said:
Hi,

I think I have come across another MoveDown/MoveUp bug in word. To begin
with, I have tested this with
- Windows 2000 Professional (No service packs and SP-4)
- Word 2000 (No service packs and SP-3)
- Screen resolutions of (1024x768) and (1280x1024)

Under particular circumstances, the MoveDown/MoveUp method will not work at
all, and no error is produced (unlike the known bug 235876)

To make this happen you first need to start Word, and exit it with the word
window in the following state:

- The Word window height less than 1/2 the height of the vertical screen
resolution
- The bottom of the Word window must be in the lower 1/2 of the screen

Next, start word and close all open documents. Then run a macro which does
the following
- Minimizes word &
- Then utilizes MoveUp/MoveDown

NOTE: The bug will not manifest itself if
- There is already a document open
- Or the application window is visible on the screen.

I have written a macro which should reproduce the problem. What will happen
is:

- Bug NOT exhibited: There will be 9 empty/blank lines in the document
- Bug IS exhibited: There will be 9 lines containing the text Line[1-9]

To stop the bug from exhibiting, you must start & then exit word with in the
following state:

- The word window height more than 1/2 the height of the vertical screen
resolution.

NOTE: Maximizing the window does NOT affect the window height. The window
must be in 'Restore Down' mode

Then restart word and run the macro. The bug should not be produced

'------ START HERE ------
Sub RunIt()
' Close all the documents
If (Documents.Count > 0) Then
Call Application.Documents.Close(wdDoNotSaveChanges)
End If

' Minimize the application window
Let Application.WindowState = wdWindowStateMinimize

' Create a new document
Call Documents.Add.Activate

' Insert some text
Dim i As Integer
For i = 1 To 9
Call Selection.InsertAfter("Line" & i & vbCrLf)
Next i
Call Selection.InsertAfter("Line" & i + 1)

' Go to the last line
Call Selection.GoTo(wdGoToLine, wdGoToLast)

' Start deleting text
For i = 1 To 10
Call Selection.MoveRight(wdWord, 1, wdExtend)
Call Selection.Range.Delete
Call Selection.MoveUp(wdLine, 1, wdMove)
Next

' Restore the window
Let Application.WindowState = wdWindowStateMaximize

' Goto the first line (i.e. scroll up)
Call Selection.GoTo(wdLine, wdFirst)
End Sub
'------ END HERE ------

I would be very interested to hear if other people can reproduce this.

Thanks, Nick

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.
http://www.microsoft.com/office/community/en-us/default.mspx?mid=6752c14e-4d
bc-43bd-a137-85809136c67c&dg=microsoft.public.word.vba.general
 
N

Nick Maddern

Hi Tony,

Thanks for your suggestion. I have tried it, but unfortunately the symptoms
still persist.

Secondly, I think it is bizarre behaviour from Word that the bug is related
to the window size & position from when you last exit the application... I
think the problem goes much deeper than not having a proper handle on the
window.

This problem will also manifest itself if it on the first time you run Word.
I think this is due to the Data registry value not being present (i.e. there
is no 'previous window size & position'). This can be tested by simply
renaming the HKCU Office key.

Currently, the only way I can see round this issue is to create an addin
that resizes word on exit to an acceptable size.

Any other ideas would be greatly appreciated!

Cheers, Nick

Tony Jollans said:
I don't get quite the same as you say, but certainly not correct results.

I suspect that working with the selection (a property of the window) when
you haven't got a proper window is the reason. Putting
Application.ScreenRefresh between adding and deleting the lines sorts it
out.

--
Enjoy,
Tony


Nick Maddern said:
Hi,

I think I have come across another MoveDown/MoveUp bug in word. To begin
with, I have tested this with
- Windows 2000 Professional (No service packs and SP-4)
- Word 2000 (No service packs and SP-3)
- Screen resolutions of (1024x768) and (1280x1024)

Under particular circumstances, the MoveDown/MoveUp method will not work at
all, and no error is produced (unlike the known bug 235876)

To make this happen you first need to start Word, and exit it with the word
window in the following state:

- The Word window height less than 1/2 the height of the vertical screen
resolution
- The bottom of the Word window must be in the lower 1/2 of the screen

Next, start word and close all open documents. Then run a macro which does
the following
- Minimizes word &
- Then utilizes MoveUp/MoveDown

NOTE: The bug will not manifest itself if
- There is already a document open
- Or the application window is visible on the screen.

I have written a macro which should reproduce the problem. What will happen
is:

- Bug NOT exhibited: There will be 9 empty/blank lines in the document
- Bug IS exhibited: There will be 9 lines containing the text Line[1-9]

To stop the bug from exhibiting, you must start & then exit word with in the
following state:

- The word window height more than 1/2 the height of the vertical screen
resolution.

NOTE: Maximizing the window does NOT affect the window height. The window
must be in 'Restore Down' mode

Then restart word and run the macro. The bug should not be produced

'------ START HERE ------
Sub RunIt()
' Close all the documents
If (Documents.Count > 0) Then
Call Application.Documents.Close(wdDoNotSaveChanges)
End If

' Minimize the application window
Let Application.WindowState = wdWindowStateMinimize

' Create a new document
Call Documents.Add.Activate

' Insert some text
Dim i As Integer
For i = 1 To 9
Call Selection.InsertAfter("Line" & i & vbCrLf)
Next i
Call Selection.InsertAfter("Line" & i + 1)

' Go to the last line
Call Selection.GoTo(wdGoToLine, wdGoToLast)

' Start deleting text
For i = 1 To 10
Call Selection.MoveRight(wdWord, 1, wdExtend)
Call Selection.Range.Delete
Call Selection.MoveUp(wdLine, 1, wdMove)
Next

' Restore the window
Let Application.WindowState = wdWindowStateMaximize

' Goto the first line (i.e. scroll up)
Call Selection.GoTo(wdLine, wdFirst)
End Sub
'------ END HERE ------

I would be very interested to hear if other people can reproduce this.

Thanks, Nick

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.
http://www.microsoft.com/office/community/en-us/default.mspx?mid=6752c14e-4d
bc-43bd-a137-85809136c67c&dg=microsoft.public.word.vba.general
 
T

Tony Jollans

Hi Nick,

I certainly haven't exhaustively tested but the window size and position
didn't seem to make a difference for me. But, even accepting it as a bug,
this is all rather esoteric - under what real circumstances do you hit this
problem?

--
Enjoy,
Tony


Nick Maddern said:
Hi Tony,

Thanks for your suggestion. I have tried it, but unfortunately the symptoms
still persist.

Secondly, I think it is bizarre behaviour from Word that the bug is related
to the window size & position from when you last exit the application... I
think the problem goes much deeper than not having a proper handle on the
window.

This problem will also manifest itself if it on the first time you run Word.
I think this is due to the Data registry value not being present (i.e. there
is no 'previous window size & position'). This can be tested by simply
renaming the HKCU Office key.

Currently, the only way I can see round this issue is to create an addin
that resizes word on exit to an acceptable size.

Any other ideas would be greatly appreciated!

Cheers, Nick

Tony Jollans said:
I don't get quite the same as you say, but certainly not correct results.

I suspect that working with the selection (a property of the window) when
you haven't got a proper window is the reason. Putting
Application.ScreenRefresh between adding and deleting the lines sorts it
out.

--
Enjoy,
Tony


Nick Maddern said:
Hi,

I think I have come across another MoveDown/MoveUp bug in word. To begin
with, I have tested this with
- Windows 2000 Professional (No service packs and SP-4)
- Word 2000 (No service packs and SP-3)
- Screen resolutions of (1024x768) and (1280x1024)

Under particular circumstances, the MoveDown/MoveUp method will not
work
at
all, and no error is produced (unlike the known bug 235876)

To make this happen you first need to start Word, and exit it with the word
window in the following state:

- The Word window height less than 1/2 the height of the vertical screen
resolution
- The bottom of the Word window must be in the lower 1/2 of the screen

Next, start word and close all open documents. Then run a macro which does
the following
- Minimizes word &
- Then utilizes MoveUp/MoveDown

NOTE: The bug will not manifest itself if
- There is already a document open
- Or the application window is visible on the screen.

I have written a macro which should reproduce the problem. What will happen
is:

- Bug NOT exhibited: There will be 9 empty/blank lines in the document
- Bug IS exhibited: There will be 9 lines containing the text Line[1-9]

To stop the bug from exhibiting, you must start & then exit word with
in
the
following state:

- The word window height more than 1/2 the height of the vertical screen
resolution.

NOTE: Maximizing the window does NOT affect the window height. The window
must be in 'Restore Down' mode

Then restart word and run the macro. The bug should not be produced

'------ START HERE ------
Sub RunIt()
' Close all the documents
If (Documents.Count > 0) Then
Call Application.Documents.Close(wdDoNotSaveChanges)
End If

' Minimize the application window
Let Application.WindowState = wdWindowStateMinimize

' Create a new document
Call Documents.Add.Activate

' Insert some text
Dim i As Integer
For i = 1 To 9
Call Selection.InsertAfter("Line" & i & vbCrLf)
Next i
Call Selection.InsertAfter("Line" & i + 1)

' Go to the last line
Call Selection.GoTo(wdGoToLine, wdGoToLast)

' Start deleting text
For i = 1 To 10
Call Selection.MoveRight(wdWord, 1, wdExtend)
Call Selection.Range.Delete
Call Selection.MoveUp(wdLine, 1, wdMove)
Next

' Restore the window
Let Application.WindowState = wdWindowStateMaximize

' Goto the first line (i.e. scroll up)
Call Selection.GoTo(wdLine, wdFirst)
End Sub
'------ END HERE ------

I would be very interested to hear if other people can reproduce this.

Thanks, Nick
follow
this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.
http://www.microsoft.com/office/community/en-us/default.mspx?mid=6752c14e-4d
bc-43bd-a137-85809136c67c&dg=microsoft.public.word.vba.general
 
J

Jean-Guy Marcil

Tony Jollans was telling us:
Tony Jollans nous racontait que :
Hi Nick,

I certainly haven't exhaustively tested but the window size and
position didn't seem to make a difference for me. But, even accepting
it as a bug, this is all rather esoteric - under what real
circumstances do you hit this problem?

And, to top it off... all this is predicated on using the Selection object,
which really should not be used as it is used in the example provided.

A Range objectis more reliable, faster and would certainly not create this
so-called bug.

This is just another example that re-enforces my conviction about not using
the Selection object unless I really need to...

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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