Analisa “parágrafos” no cabeçalho / rodapé

0

Estou tentando varrer várias linhas de "texto" (o único texto é imagens em linha) em um cabeçalho, para que eu possa ocultar condicionalmente as linhas que são desnecessárias com base nas especificações do usuário. Então eu tenho um cabeçalho com várias linhas, cada linha contendo uma tag e uma ou duas imagens exclusivas. Quero mostrar apenas a linha com a tag correta e ocultar todas as outras. A tag tem o formato <#>, onde # é um Integer de 1 a 8.

Eu consegui fazer isso com parágrafos no corpo principal, o que funciona bem. No entanto, o mesmo código adaptado para cabeçalhos não funciona:

'Determine if each paragraph matches show or hide group.
'First, check for tag character < and ignore any paragraphs that don't begin with this character.
'If input value and tag value match, hide <#> tag.
For Each sSection In ActiveDocument.Sections
'If input value and tag value match, hide <#> tag.
    For Each myPara In sSection.Headers(wdHeaderFooterPrimary).Range.Paragraphs
        If InStr(1, myPara, "<") Then
            If ToShow = myPara.Range.Characters(2) Then
                myRange.SetRange Start:=myPara.Range.Start, End:=myPara.Range.Start + 3
                myRange.Font.Hidden = True
            End If
        End If
    Next
'If input value and tag don't match, hide paragraph
    For Each myPara In sSection.Headers(wdHeaderFooterPrimary).Range.Paragraphs
    If InStr(1, myPara, "<") Then
        If ToShow <> myPara.Range.Characters(2) Then myPara.Range.Font.Hidden = True
    End If
    Next
Next

Estou assumindo que o problema é que os cabeçalhos não contêm parágrafos, mas algum outro tipo de objeto. O que posso usar para digitalizar meus cabeçalhos linha por linha para obter o resultado desejado?

    
por mykrus 23.12.2017 / 01:08

0 respostas