Update fields with no screen blinks

  • Thread starter Peter van de Kerkhof
  • Start date
P

Peter van de Kerkhof

Hi

I want to update all fields in a document.

Dim aTOC As TableOfContents
For Each aTOC In ActiveDocument.TablesOfContents ' update all tables
aTOC.Update
Next aTOC
Selection.WholeStory ' update content
Selection.Fields.Update
Selection.HomeKey ' Unselect content
ActiveDocument.PrintPreview ' Update headers and footers
ActiveDocument.ClosePrintPreview

does the trick


But I want to avoid blinking of the screen with "Select All" and "Print
Preview", update etc.

Are there solutions for this??


Regards Peter
 
M

martinique

Instead of using the Selection object, work directly with the relevant Range
objects (It's moving the selection around that causes a lot of the flicker.)
Eg

ActiveDocument.WholeStory.Fields.Update

etc.

You can also switch off ScreenUpdating:

Application.ScreenUpdating = FALSE (remember to set it back to TRUE when
your code is finished)


By the way, if you're updating all fields in the document, you don't need to
update the TOCs separately -- they are fields too. But your updating (as you
have it) will miss fields not in the body of the document (eg fields in
headers and footers, textboxes, etc).
 
P

Peter van de Kerkhof

Martinique

The line:
ActiveDocument.WholeStory.Fields.Update
in this code

Sub Update_Fields()
Application.ScreenUpdating = FALSE
ActiveDocument.WholeStory.Fields.Update
ActiveDocument.PrintPreview
ActiveDocument.ClosePrintPreview
Selection.HomeKey
Application.ScreenUpdating = True
End Sub

Generates an error 438 Not support method or object

But the other stuf seems to work.

Thanks
 
M

Mark Tangard

Peter,

The .WholeStory is a property of the Selection object. For
this code you want ActiveDocument.Range.Fields.Update.
 
P

Peter van de Kerkhof

martinique,

This works without the: Application.ScreenUpdating = False
only I had to use:
Dim sry
Dim sry2

Typecasting to StoryRange(s) gave a problem!

Tanks to you all
 

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