Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #9  
Old 03-14-2021, 03:38 AM
AnBad AnBad is offline Hide Text in a document. Windows 10 Hide Text in a document. Office 2019
Novice
Hide Text in a document.
 
Join Date: Mar 2021
Posts: 5
AnBad is on a distinguished road
Default

Hello,

I am trying to put all NOT hidden Bookmarks into an Array. But it want work, because of the 9s-fault, because

Code:
ActiveDocument.Bookmarks(MyRange.Bookmarks(x).Name).Range.Font.Hidden = False
want work.

I solved this issue by adding some Bookmarks_dummy into the faulty ranges with only view words in these. Now the code recognizes the Bookmarks and with repace() I delete the "_dummy". At the end I got my list. But its not the way as it should be. I would prefer a clean solution.

I use this code (here without my dummy-Replasement)

Code:
Sub useFormInhaltFuellen()
'nach Reihenfolge im Doku sortiert
'ohne Kopf- und Fußzeile
Dim aDoc As Word.Document
Dim nDoc As Word.Document
Dim x As Long, i As Long
Dim MyRange As Word.Range
Dim v As String
Set aDoc = ActiveDocument
If aDoc.Bookmarks.Count < 1 Then
    MsgBox "kein Textmarken im Dokument enthalten!"
    Exit Sub
End If

i = 0
ReDim strArray(aDoc.Bookmarks.Count, 0)
For Each MyRange In aDoc.StoryRanges
    Do While Not MyRange Is Nothing
        v = MyRange.StoryType
            If MyRange.StoryType = wdMainTextStory Then
                For x = 1 To MyRange.Bookmarks.Count
                    If ActiveDocument.Bookmarks(MyRange.Bookmarks(x).Name).Range.Font.Hidden = False Then
                        strArray(i, 0) = MyRange.Bookmarks(x).Name
                        i = i + 1
                    End If
                Next x
            End If
        Set MyRange = MyRange.NextStoryRange
    Loop
Next

'Listbox1 eintragen
ufInhalt.ListBox1.List = strArray
End Sub
Thank you for your help.

Kind regards
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to text heading1 text heading1 text? How to collapse or hide text in the middle of a line. TImer Word 7 08-10-2020 12:52 AM
Conditionally hide parts of a document elaineAda Word VBA 0 04-01-2019 10:00 PM
Hide Text in a document. How to manage (display/hide) parts of the text within a document via table of content Curby Word 2 06-30-2016 12:29 AM
Page nos in footers - how to hide mid document willynilly Word 2 11-22-2013 07:21 AM
Hide Text in a document. Hide sentances in a word document michaelgott Word 1 04-19-2012 08:11 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:42 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft