Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2006

Tip: Looking for answers? Try searching our database.

*Another* MoveDown bug in Word?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nick Maddern - 25 Oct 2006 00:52 GMT
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
Tony Jollans - 25 Oct 2006 10:53 GMT
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

> Hi,
>
[quoted text clipped - 88 lines]
> 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
Nick Maddern - 25 Oct 2006 23:18 GMT
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

> I don't get quite the same as you say, but certainly not correct results.
>
[quoted text clipped - 107 lines]
> http://www.microsoft.com/office/community/en-us/default.mspx?mid=6752c14e-4d
> bc-43bd-a137-85809136c67c&dg=microsoft.public.word.vba.general
Tony Jollans - 26 Oct 2006 16:42 GMT
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

> Hi Tony,
>
[quoted text clipped - 126 lines]
> > > 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
Jean-Guy Marcil - 26 Oct 2006 19:57 GMT
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...

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.