{"id":407,"date":"2019-02-20T11:11:40","date_gmt":"2019-02-20T19:11:40","guid":{"rendered":"https:\/\/gantovnik.com\/bio-tips\/?p=407"},"modified":"2021-11-12T14:37:46","modified_gmt":"2021-11-12T22:37:46","slug":"updating-all-fields-automatically-in-ms-word","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2019\/02\/updating-all-fields-automatically-in-ms-word\/","title":{"rendered":"#61 Updating All Fields Automatically in MS Word"},"content":{"rendered":"<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nPublic Sub UpdateAllFields()\r\n'Programmer: Vladimir Gantovnik\r\n'Date: 01\/15\/2014\r\n  Dim rngStory As Word.Range\r\n  Dim lngJunk As Long\r\n  Dim oShp As Shape\r\n  lngJunk = ActiveDocument.Sections(1).Headers(1).Range.StoryType\r\n  For Each rngStory In ActiveDocument.StoryRanges\r\n    'Iterate through all linked stories\r\n    Do\r\n      On Error Resume Next\r\n      rngStory.Fields.Update\r\n      Select Case rngStory.StoryType\r\n        Case 6, 7, 8, 9, 10, 11\r\n          If rngStory.ShapeRange.Count &gt; 0 Then\r\n            For Each oShp In rngStory.ShapeRange\r\n              If oShp.TextFrame.HasText Then\r\n                oShp.TextFrame.TextRange.Fields.Update\r\n              End If\r\n            Next\r\n          End If\r\n        Case Else\r\n          'Do Nothing\r\n        End Select\r\n        On Error GoTo 0\r\n        'Get next linked story (if any)\r\n        Set rngStory = rngStory.NextStoryRange\r\n      Loop Until rngStory Is Nothing\r\n    Next\r\nEnd Sub\r\n<\/pre>\n<p>\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Public Sub UpdateAllFields() &#8216;Programmer: Vladimir Gantovnik &#8216;Date: 01\/15\/2014 Dim rngStory As Word.Range Dim lngJunk As Long Dim oShp As Shape lngJunk = ActiveDocument.Sections(1).Headers(1).Range.StoryType For Each rngStory In ActiveDocument.StoryRanges &#8216;Iterate through all linked stories Do On Error Resume Next rngStory.Fields.Update Select Case rngStory.StoryType Case 6, 7, 8, 9, 10, 11 If rngStory.ShapeRange.Count &gt; 0 Then For [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","_lmt_disableupdate":"yes","_lmt_disable":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[15],"tags":[16],"class_list":["post-407","post","type-post","status-publish","format-standard","hentry","category-vba","tag-vba"],"modified_by":"gantovnik","jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-6z","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":3351,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/08\/444-how-to-suppress-the-message-this-workbook-contains-links-and-automatically-select-dont-update-in-vba\/","url_meta":{"origin":407,"position":0},"title":"#444 How to suppress the message &#8220;This workbook contains links&#8221; and automatically select &#8220;Don&#8217;t Update&#8221; in VBA","author":"gantovnik","date":"2024-08-02","format":false,"excerpt":"Sub OpenWorkbookWithoutUpdatingLinks() Dim wb As Workbook Application.AskToUpdateLinks = False Set wb = Workbooks.Open(\"C:\\Path\\To\\Your\\Workbook.xlsm\", UpdateLinks:=0) Application.AskToUpdateLinks = True End Sub","rel":"","context":"In &quot;vba&quot;","block_context":{"text":"vba","link":"https:\/\/gantovnik.com\/bio-tips\/category\/vba\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2241,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/07\/433-run-a-vba-macro-when-certain-cells-change-in-excel\/","url_meta":{"origin":407,"position":1},"title":"#433 Run a VBA macro when certain cells change in Excel","author":"gantovnik","date":"2024-07-08","format":false,"excerpt":"When you type an entry in cells A1:C10 on Sheet1, a message box is displayed. In the module sheet behind Sheet1 add this script [code language=\"python\"] Private Sub Worksheet_Change(ByVal Target As Range) Dim KeyCells As Range ' The variable KeyCells contains the cells that will ' cause an alert when\u2026","rel":"","context":"In &quot;excel&quot;","block_context":{"text":"excel","link":"https:\/\/gantovnik.com\/bio-tips\/category\/excel\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1874,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/06\/353-particle-swarm-optimization-using-python\/","url_meta":{"origin":407,"position":2},"title":"#353 Particle swarm optimization using python","author":"gantovnik","date":"2023-06-28","format":false,"excerpt":"[code language=\"python\"] # pip install pyswarms from pyswarms.single.global_best import GlobalBestPSO import numpy as np # Define characteristics of variables: x_min = [0, 0] x_max = [1, 1] bounds = (x_min, x_max) dim = len(x_min) # Define settings of the algorithm: pop = 100 iterations = 250 options = {'c1': 0.5,\u2026","rel":"","context":"In &quot;optimization&quot;","block_context":{"text":"optimization","link":"https:\/\/gantovnik.com\/bio-tips\/category\/optimization\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1211,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/11\/210-parametric-curve-in-3d-2-2-2-2\/","url_meta":{"origin":407,"position":3},"title":"#214 Animated 3D random walk","author":"gantovnik","date":"2021-11-28","format":false,"excerpt":"[code language=\"python\"] import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation # Fixing random state for reproducibility np.random.seed(19680801) def random_walk(num_steps, max_step=0.05): \"\"\"Return a 3D random walk as (num_steps, 3) array.\"\"\" start_pos = np.random.random(3) steps = np.random.uniform(-max_step, max_step, size=(num_steps, 3)) walk = start_pos + np.cumsum(steps, axis=0) return walk\u2026","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex214.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex214.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex214.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":666,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/09\/112-msc-nastran-sol-106\/","url_meta":{"origin":407,"position":4},"title":"#112 MSC Nastran SOL 106","author":"gantovnik","date":"2020-09-28","format":false,"excerpt":"#112 MSC Nastran SOL 106 MSC Nastran SOL 106 The nonlinear effects in structures occur due to nonlinear material behavior and large deformations. Geometric nonlinearity becomes relevant when the structure is subjected to large displacement and rotation. Geometric nonlinearity effects are prominent in two aspects: geometric stiffening due to initial\u2026","rel":"","context":"In &quot;nastran&quot;","block_context":{"text":"nastran","link":"https:\/\/gantovnik.com\/bio-tips\/category\/nastran\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":867,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/02\/156-filtering-content-from-files-using-awk\/","url_meta":{"origin":407,"position":5},"title":"#156 Filtering content from files using awk","author":"gantovnik","date":"2021-02-09","format":false,"excerpt":"#156 Displaying and filtering the content of files with awk Using the following command, we can print all lines from the file: [code language=\"python\"] awk ' { print } ' \/etc\/passwd [\/code] This is equivalent to using the $0 variable. The $0 variables refers to the complete line. [code language=\"python\"]\u2026","rel":"","context":"In &quot;awk&quot;","block_context":{"text":"awk","link":"https:\/\/gantovnik.com\/bio-tips\/category\/awk\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/407","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/comments?post=407"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/407\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}