Collapse Word paragraph using macroI'm trying to write a macro that will expand/collapse a paragraph in Word 2007.  I have posted part of the code below, which works fine until the paragraph is more than 50 lines.  When the paragraph is more than 50 lines, the Boolean value changes to 99999 and the macro doesn't work anymore.  Am I hitting a known limitation that I just don't know about?<br/> <br/> If bkmk.Name = &quot;Grow&quot; Then<br/>         If bkmk.Range.Font.Hidden = True Then<br/>             bkmk.Range.Font.Hidden = False<br/>         Else<br/>             bkmk.Range.Font.Hidden = True<br/>         End If<br/>     End If© 2009 Microsoft Corporation. All rights reserved.Mon, 20 Jul 2009 14:32:05 Zf021b720-65b5-49ac-b80f-acfcf5203555http://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/f021b720-65b5-49ac-b80f-acfcf5203555#f021b720-65b5-49ac-b80f-acfcf5203555http://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/f021b720-65b5-49ac-b80f-acfcf5203555#f021b720-65b5-49ac-b80f-acfcf5203555123Heatherhttp://social.msdn.microsoft.com/Profile/en-US/?user=123HeatherCollapse Word paragraph using macroI'm trying to write a macro that will expand/collapse a paragraph in Word 2007.  I have posted part of the code below, which works fine until the paragraph is more than 50 lines.  When the paragraph is more than 50 lines, the Boolean value changes to 99999 and the macro doesn't work anymore.  Am I hitting a known limitation that I just don't know about?<br/> <br/> If bkmk.Name = &quot;Grow&quot; Then<br/>         If bkmk.Range.Font.Hidden = True Then<br/>             bkmk.Range.Font.Hidden = False<br/>         Else<br/>             bkmk.Range.Font.Hidden = True<br/>         End If<br/>     End IfWed, 08 Jul 2009 13:15:58 Z2009-07-08T13:15:58Zhttp://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/f021b720-65b5-49ac-b80f-acfcf5203555#495fb9a6-14d2-4f03-b7ec-95b6eb880c3dhttp://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/f021b720-65b5-49ac-b80f-acfcf5203555#495fb9a6-14d2-4f03-b7ec-95b6eb880c3dShasurhttp://social.msdn.microsoft.com/Profile/en-US/?user=ShasurCollapse Word paragraph using macro<p>Mostly this '99999' occurs when there are mixed results - if some lines in the range are hidden and some are not. But this is a strange behavior, might be a bug in Office.</p> <p>If that is the case then you need to have some workaround like this</p> <pre lang=x-vbnet>Sub asasa() Dim bkmk As Bookmark Dim line1 As Line If bkmk.Name = &quot;Grow&quot; Then If bkmk.Range.Font.Hidden = True Then bkmk.Range.Font.Hidden = False ElseIf bkmk.Range.Font.Hidden = True Then bkmk.Range.Font.Hidden = True Else For Each p1 In bkmk.Range.Paragraphs If p1.Range.Font.Hidden = True Then p1.Range.Font.Hidden = False End If Next p1 End If End If End Sub </pre> <br/>Cheers<br/>Shasur<hr class="sig">http://www.vbadud.blogspot.comThu, 09 Jul 2009 14:39:01 Z2009-07-09T14:39:01Zhttp://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/f021b720-65b5-49ac-b80f-acfcf5203555#35a4368f-56e9-4915-9652-ed19d3c899c0http://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/f021b720-65b5-49ac-b80f-acfcf5203555#35a4368f-56e9-4915-9652-ed19d3c899c0123Heatherhttp://social.msdn.microsoft.com/Profile/en-US/?user=123HeatherCollapse Word paragraph using macroShasur, I tried using the example you provided.....is p1 meant to be line1 as you defined earlier?<br/><br/>Thanks,<br/>HeatherWed, 15 Jul 2009 17:21:48 Z2009-07-15T17:21:48Zhttp://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/f021b720-65b5-49ac-b80f-acfcf5203555#5bb390df-9fb8-444c-8af8-9b8a6ad3210chttp://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/f021b720-65b5-49ac-b80f-acfcf5203555#5bb390df-9fb8-444c-8af8-9b8a6ad3210cShasurhttp://social.msdn.microsoft.com/Profile/en-US/?user=ShasurCollapse Word paragraph using macro<p>Hi Heather<br/><br/>P1 refers to paragraph (each paragraph in the bookmark range)<br/><br/>Cheers<br/>Shasur</p><hr class="sig">http://www.vbadud.blogspot.comSat, 18 Jul 2009 04:21:06 Z2009-07-18T04:21:06Zhttp://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/f021b720-65b5-49ac-b80f-acfcf5203555#cb529d2c-f8f2-4b21-a9d9-6d63443a1d7bhttp://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/f021b720-65b5-49ac-b80f-acfcf5203555#cb529d2c-f8f2-4b21-a9d9-6d63443a1d7b123Heatherhttp://social.msdn.microsoft.com/Profile/en-US/?user=123HeatherCollapse Word paragraph using macroOk, I have modified my code to this:<br/><br/>Dim bkmk As Bookmark<br/>Dim line1 As Line<br/>Dim p1 As Paragraph<br/> <br/>For Each bkmk In ActiveDocument.Bookmarks<br/>    If bkmk.Name = &quot;Grow&quot; Then<br/>            If bkmk.Range.Font.Hidden = True Then<br/>           <br/>            For Each p1 In bkmk.Range.Paragraphs<br/>                p1.Range.Font.Hidden = False<br/><br/>            Next p1<br/>          <br/>        Else<br/>            <br/>            For Each p1 In bkmk.Range.Paragraphs<br/>                p1.Range.Font.Hidden = True<br/>            Next p1<br/>            <br/>        End If<br/>    End If<br/>Next bkmk<br/><br/><br/>But it still doesn't work over 50 lines.  Has anyone been able to change the font to hidden for more than 50 lines?<br/><br/>Thanks<br/>HeatherMon, 20 Jul 2009 14:32:05 Z2009-07-20T14:32:05Z