• returning if picture object is in selection

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » returning if picture object is in selection

    Author
    Topic
    #351498

    I need to determine if a picture object or logo is stored in a header.
    I have the following code.

    Set rangeHeader = ActiveDocument.Sections(x).Headers(wdHeaderFooterFirstPage).Range
    rangeHeader.Select

    If (Selection.Type = wdInlineShapeEmbeddedOLEObject) Or (Selection.Type = wdInlineShapeLinkedOLEObject) Or (Selection.Type = wdInlineShapeLinkedPicture) Or (Selection.Type = wdInlineShapeOLEControlObject) Or (Selection.Type = wdInlineShapePicture) Then

    MsgBox (“Pic found”)
    ‘perform other code

    The problem I’m having with the above code is when I test on a current document that has a logo returns true.
    However when I testing on a doc that doesnt have logo in header still returns TRUE.

    Does anyone know/have code to obtain the correct information.
    Thanks in advance!
    Diana

    Viewing 0 reply threads
    Author
    Replies
    • #508695

      Hi Diana,

      What about:

      Set rangeHeader = ActiveDocument.Sections(x).Headers(wdHeaderFooterFirstPage).Range
      If rangeHeader.InlineShapes.Count > 0 Then 'etc.
      

      Gary

      • #508706

        Thanks Gary – that worked –
        If rangeHeader.InlineShapes.Count > 0 Then

        I previoulsy had used the below code ‘Shapes’ & wasnt working.
        intShapeCount = 0
        intShapeCount = ActiveDocument.Sections(x).Headers(wdHeaderFooterPrimary).Shapes.Count
        If intShapeCount = 0 Then
        ‘perform logic

        Diana

    Viewing 0 reply threads
    Reply To: returning if picture object is in selection

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: