Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-15-2022, 08:55 AM
Netforward Netforward is offline Windows 11 Office 2019
Novice
 
Join Date: Dec 2022
Posts: 2
Netforward is on a distinguished road
Default Wie überprüfe ich, ob ein bestimmtes Inhaltssteuerelement per TAG in einer Kopfzeile vorhanden ist?


Hallo,
ich möchte gerne per VBA prüfen lassen, ob ein bestimmtes Inhaltssteuerelement per TAG im Worddokument vorhanden ist. Mein Problem ist aber, dass dieses Inhaltssteuerelement in der Kopfzeile von Word vorhanden ist. Wie könnte ich das dann per VBA überprüfen?
Reply With Quote
  #2  
Old 12-16-2022, 03:12 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Rufen Sie die folgende Funktion auf, um zu ermitteln, ob das Inhaltssteuerungs-Tag in einem Header-Bereich vorhanden ist.

Code:
Function CCExistsInHeader(sTag As String) As Boolean
Dim oSection As Section
Dim oHeader As HeaderFooter
Dim oCC As ContentControl
    For Each oSection In ActiveDocument.Sections
        For Each oHeader In oSection.Headers
            If oHeader.Exists Then
                For Each oCC In oHeader.Range.ContentControls
                    If oCC.Tag = sTag Then
                        CCExistsInHeader = True
                        GoTo lbl_Exit
                    End If
                Next oCC
            End If
        Next oHeader
    Next oSection
lbl_Exit:
    Set oSection = Nothing
    Set oHeader = Nothing
    Set oCC = Nothing
    Exit Function
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 12-16-2022, 03:46 PM
Netforward Netforward is offline Windows 11 Office 2019
Novice
 
Join Date: Dec 2022
Posts: 2
Netforward is on a distinguished road
Default

Super, vielen Dank! Das war genau das, was ich brauchte. Funktioniert super!!!
Reply With Quote
Reply



Other Forums: Access Forums

All times are GMT -7. The time now is 03:47 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