From: Wayne on 7 Apr 2010 22:16 Hi, I'd like to update all of the fields in my document when the doc is opened. To do this, I have put ActiveDocument.Fields.Update in the AutoOpen() macro. This works, except for the fields that are dependant on the number of pages in the document. By examining the value of the "Number of pages" property in ActiveDocument.BuiltInDocumentProperties when the macro runs, I see that the number of pages is 3 ( there are actually 26 in my test document ) when the macro runs. If I manually run the macro, the number of pages in this property is correct. I also found that if I stop the macro for a few seconds, eg by putting a Stop or breakpoint in, the Number of pages property gets updated correctly ( at the same time, I can see the scrollbar changing to reflect the increasing length of the document ). So, it seems that the AutoOpen() macro runs after the document is loaded into memory ( the full contents are available to the macro ), but before the document is rendered. Is there a way to run a macro after the document is rendered / pagination is finished, or to pause AutoOpen() without user action to restart? Or is there perhaps a better way to update these fields? thanks, Wayne. Submitted via EggHeadCafe - Software Developer Portal of Choice WPF Datagrid as ComboBox Dropdown Part 2 http://www.eggheadcafe.com/tutorials/aspnet/5af72df7-5b0b-4ac2-be96-e24127040bbf/wpf-datagrid-as-combobox.aspx
From: Jay Freedman on 7 Apr 2010 23:16 Use the OnTime technique shown in http://word.mvps.org/faqs/userforms/AutoExecUsertFm.htm. Just replace the "Tempfm.Show" statement with the ActiveDocument.Fields.Update statement. Of course, it would be appropriate to rename the ShowForm macro to something like UpdateAll. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. On Wed, 07 Apr 2010 19:16:39 -0700, Wayne Butterworth wrote: >Hi, > >I'd like to update all of the fields in my document when the doc is opened. To do this, I have put ActiveDocument.Fields.Update in the AutoOpen() macro. >This works, except for the fields that are dependant on the number of pages in the document. > >By examining the value of the "Number of pages" property in ActiveDocument.BuiltInDocumentProperties when the macro runs, I see that the number of pages is 3 ( there are actually 26 in my test document ) when the macro runs. If I manually run the macro, the number of pages in this property is correct. > >I also found that if I stop the macro for a few seconds, eg by putting a Stop or breakpoint in, the Number of pages property gets updated correctly ( at the same time, I can see the scrollbar changing to reflect the increasing length of the document ). > >So, it seems that the AutoOpen() macro runs after the document is loaded into memory ( the full contents are available to the macro ), but before the document is rendered. Is there a way to run a macro after the document is rendered / pagination is finished, or to pause AutoOpen() without user action to restart? Or is there perhaps a better way to update these fields? > >thanks, > > >Wayne. > > >Submitted via EggHeadCafe - Software Developer Portal of Choice >WPF Datagrid as ComboBox Dropdown Part 2 >http://www.eggheadcafe.com/tutorials/aspnet/5af72df7-5b0b-4ac2-be96-e24127040bbf/wpf-datagrid-as-combobox.aspx
|
Pages: 1 Prev: Adding a row to a protected table - (attn: G. Mayor) Next: Autotext entries in .dotm templates |