title: using macro to expand subdocuments
body: <p>I have a word document (word 2013) made of sub-documents.</p>
  <p>To produce the final doc, I have to :</p>
  <blockquote>
  <ul>
  <li>View-&gt;Outline</li>
  </ul>
  </blockquote>
  <p>Then, click on 'Expand subdocument' and close the outline view via 'Close outline view' button.</p>
  <p>I am trying to write a macro that does this automatically (using the macro recorder in first place to find the right commands).
  But I fail to have the equivalent of 'Close outline view'.</p>
  <pre><code>ActiveWindow.ActivePane.View.Type = wdOutlineView
  ActiveDocument.Subdocuments.Expanded = True
  </code></pre>
  <p>I have then added the following statement, hoping it will close the outline view, but not:</p>
  <pre><code>ActiveWindow.ActivePane.View.Type = wdNormalView
  </code></pre>
  <p>Using the hint provided by <a href="https://stackoverflow.com/users/2574177/bmgh1985">bmgh1985</a>, I have modified this last statement by :</p>
  <pre><code>ActiveWindow.ActivePane.View.Type = 3
  </code></pre>
  <p>But Word hangs up : the expansion of <code>Subdocument</code> is an asynchronous processing (triggered by the modification of the Expanded property), word is expanding the <code>Subdocument</code>while the view is reverted back to the normal one.</p>
  <p>Is there a way to wait for the end of the expansion of <code>Subdocument</code>? (I have tried to use a timer, and a big loop, but no way....)</p>