Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Word screen jumps after macro

Status
Not open for further replies.

paradiso

Programmer
Apr 18, 2002
60
US
Friends,

I run VBA code in macros behind form fields in a Word document. In general, this code updates values further down on the page. As an example, when the user clicks on a check mark, the tally field at the bottom of the row of checks is updated.

Trouble is that the screen jumps and realigns itself when the code runs. It repositions the cursor to the next logical form field, but relocates that field to the top of the page. Therefore, if someone was updating a field in the middle of their screen, that field then is suddenly shifted to the top.

I have enclosed each subroutine in the screenupdating commands

Application.ScreenUpdating = False
<code>
Application.ScreenUpdating = True

Still my cursor leaps. Very offputting in an otherwise useful form.

Am I missing something.

thanks and best regards,
p
 
Hi again,

When I enter a value in a goal priority field, I update the total priority percentage by totalling all six priority fields. If the field I update is in the middle of my screen, the macro runs and then the cursor tabs to the next field, which is jammed up to the top of the screen. I want the cursor to proceed as it should, but I want screen to stay put.

Here's the sample subroutine:

Public Sub UpdateTotalTargetPct()
Dim intCounter As Integer
Dim intRunningTotal As Integer
Dim strFieldName As String
Dim intCurrentValue As Integer

'Stop
Application.ScreenUpdating = False

intRunningTotal = 0

For intCounter = 1 To 6
strFieldName = "GoalPct_" & CStr(intCounter)
intCurrentValue = CInt(Me.FormFields(strFieldName).Result)
intRunningTotal = intRunningTotal + intCurrentValue
Next intCounter

If intRunningTotal > 100 Then
MsgBox "Sorry, the total of the Goal Priority percentages is over 100. Please revisit these numbers."
End If

Me.FormFields("TotalTargetPct").Result = intRunningTotal

Application.ScreenUpdating = True

End Sub


thx,
p
 
Curious - I'm running this on Word (Office) XP. Word 2002 version 10.2627.2625. Macro Security is set to Medium.

The code is called as a macro, on exit from the form field. The same macros is invoked on each of the six fields. Similar structures exist for my check boxes. One macro assigned to various boxes, to update a tally field.

best,
p
 
So...you run the same macro from ALL of the formfields? So any time ANY of them are changed your total is adjusted. OK...Hmmmmmm. Something is odd somewhere. I can not duplicate this.

Gerry
See my Paintings and Sculpture
 
An idea --

Since I'm running this subroutine each time a user updates a value, and I'm turning screenupdating off and then back on each time, it makes sense that it is updating each time.

Can I just turn off screenupdating for the duration? What would that do?

p
 
Hi again,

My understanding is that ScreenRefresh is a command to do just that. I don't see a True/False property as I see in ScreenUpdating. How does one turn ScreenRefresh off?

best to you,
p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top