Share via

Update ask field on open using autoexec macro doesn't work

Anonymous
2011-07-31T22:08:20+00:00

I have a word template with an ask field (followed by reference field). When I select all and then press F9, the dialog box shows up, and the response is correctly updated in the document. What I am trying to do is have that process happen when the document opens. I have the following code in an 'autoexec' macro but it does not work. Any help is greatly appreciated. Thank you.

Sub autoexec()

     SendKeys "^{A}"

      SendKeys "{F9}"

End Sub

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2011-07-31T22:30:21+00:00

AutoExec is run when Word is started, not when a document is created/opened.

Either create an AutoNew and an AutoOpen macro in a standard module in the template:

Sub AutoNew()

    ActiveDocument.Fields.Update

End Sub

Sub AutoOpen()

ActiveDocument.Fields.Update

End Sub

or create Document_New and Document_Open event procedures in the ThisDocument module of the template:

Private Sub Document_New()

    ActiveDocument.Fields.Update

End Sub

Private Sub Document_Open()

    ActiveDocument.Fields.Update

End Sub

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful