View Single Post
 
Old 10-23-2025, 01:33 AM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,527
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

See the attached Word template.

For an explanation of the approach taken, see: https://wordmvp.com/FAQs/MacrosVBA/AppClassEvents.htm

The code requires two modules:

• A standard code module containing:
Code:
Dim wdAppClass As New ThisApplication

Public Sub AutoExec()
Set wdAppClass.wdApp = Word.Application
End Sub
It doesn't matter what name you give this module. If you already have a standard code module, simply put this code at the top.

• A class module named 'ThisApplication' containing:
Code:
Public WithEvents wdApp As Word.Application

Private Sub wdApp_WindowSelectionChange(ByVal Sel As Selection)
Application.ScreenUpdating = False
If Sel.Information(wdWithInTable) <> True Then Exit Sub
If Sel.Tables(1).Range.Fields.Count > 0 Then Sel.Tables(1).Range.Fields.Update
Application.ScreenUpdating = True
End Sub
You can either add those modules and code to your own document's template, or you can attach you document to the template in the attachment.
Attached Files
File Type: dotm Table.dotm (27.6 KB, 3 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote