Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    returning if picture object is in selection

    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(wdHeaderFooterF irstPage).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

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 28 Times in 27 Posts

    Re: returning if picture object is in selection

    Hi Diana,

    What about:
    <pre>Set rangeHeader = ActiveDocument.Sections(x).Headers(wdHeaderFooterF irstPage).Range
    If rangeHeader.InlineShapes.Count > 0 Then 'etc.
    </pre>

    Gary

  4. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: returning if picture object is in selection

    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(wdHeaderFooterP rimary).Shapes.Count
    If intShapeCount = 0 Then
    'perform logic

    Diana

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •