News, tips, advice, support for Windows, Office, PCs & more. Tech help. No bull. We're community supported by donations from our Plus Members, and proud of it
Home icon Home icon Home icon Email icon RSS icon
  • returning if picture object is in selection

    Posted on WSDiana Comment on the AskWoody Lounge

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

    Viewing 1 reply thread
    • Author
      Posts
      • #351498 Reply
        WSDiana
        AskWoody Lounger

        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

      • #508695 Reply
        WSGary Frieder
        AskWoody Lounger

        Hi Diana,

        What about:

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

        Gary

        • #508706 Reply
          WSDiana
          AskWoody Lounger

          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 1 reply thread

    Please follow the -Lounge Rules- no personal attacks, no swearing, and politics/religion are relegated to the Rants forum.

    Reply To: returning if picture object is in selection

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