Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Kamran Kamran is offline
external usenet poster
 
Posts: 80
Default Updating fields using screen update doesn't work with command butt

Hello,
The code below works perfectly when tabbing away from a form entry field
that runs the macro on exit, but breaks on the second line when activated in
a Private Sub from a command button -- why?

Application.ScreenUpdating = False
ActiveDocument.PrintPreview
ActiveDocument.ClosePrintPreview
Application.ScreenUpdating = True

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Cindy M. Cindy M. is offline
external usenet poster
 
Posts: 2,416
Default Updating fields using screen update doesn't work with command butt

Hi Kamran,

The code below works perfectly when tabbing away from a form entry field
that runs the macro on exit, but breaks on the second line when activated in
a Private Sub from a command button -- why?

Application.ScreenUpdating = False
ActiveDocument.PrintPreview
ActiveDocument.ClosePrintPreview
Application.ScreenUpdating = True

I'm not sure I'm following the "activated in a Private Sub from a command
button" part - I'm not sure I understand what all is involved. Best guess:

The "command button" is an ActiveX control from the Controls Toolbox. When it's
clicked, the focus is on the button. Possibly, due to this, Word can't change
the view to Print Preview.

As you've posted this in an end-user group, you might want to pursue in a
word.programming newsgroup, instead. You're more likely to find a broad range
of people with some experience in the question. When you post a question, don't
forget to mention the *version* of the software involved!

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)

  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Kamran Kamran is offline
external usenet poster
 
Posts: 80
Default Updating fields using screen update doesn't work with command

Hi, Cindy. Thanks for the remind on providing more info, will do (this is on
Word 2003). I think you're right about the focus on the button. I had the
code above in the sub for a command button click so that it would update a
formula SUM field, but it wouldn't work. Instead I came up with the idea to
assign a "Score" bookmark to the field and just update it directly. Hope
that makes sense.

Private Sub CommandButton1_Click()
ActiveDocument.Variables("var1").Value = 2
ActiveDocument.Bookmarks("Score").Range.Fields.Upd ate
End Sub
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating Normal style does not update all styles in document ChristyL Microsoft Word Help 1 June 16th 08 05:59 PM
Automatic template update isn't updating docs Hans Page Layout 3 February 6th 08 11:11 AM
Command to pull insertion point to top of screen? Ed from AZ Microsoft Word Help 1 November 2nd 07 07:27 PM
The FILE command does not appear at the top of my word screen. JD Microsoft Word Help 3 October 10th 06 08:42 PM
confirm SQL command after windows update Chris Mailmerge 1 December 1st 04 12:03 PM


All times are GMT +1. The time now is 04:49 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"