Consulting

Results 1 to 5 of 5

Thread: Easy one to get started

  1. #1
    VBAX Newbie
    Joined
    May 2021
    Location
    UK
    Posts
    4
    Location

    Easy one to get started

    Hi all, I have a 199 page document that I need to 'process'. I used to be fairly handy with macros but haven't touched them for 10years + so a little rusty. The document is a PDF that has been imported to word so won't be 'set up' in a standard way.

    First job - there is a watermark on each page that I need to get rid of. It s not in 'master pages' but rather appears as a different image on each page.

    I've recorded a macro to get started and it seems that the image is called Picture <X> with x being incremented on each page .... so what I want is along the lines of:
    For x = 1 To 199 ActivePage.Shapes("Picture" & x).Select
    Selection.ShapeRange.Delete
    Application.Browser.Next
    next x

    You might not be surprised to hear that this doesn't work. The error returned is RunTime error 424: Object Required.

    Any thoughts?

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,704
    Location
    I don't do much Word, but assuming the rest of your Properties are correct, the No Object error, suggests that you need to declare the Object those Properties are "Childs" of

    Maybe something like
    For x = 1 to 199
       ActiveDoc.Shapes("Picture" & x).ShapeRange.Delete '<-- I dunno "ActiveDoc is right
    Next
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,311
    Location
    For x = 1 to 199
       ActiveDocument.Shapes("Picture" & x).Delete
    Next
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  4. #4
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,311
    Location
    Cross-posted at: https://www.excelforum.com/word-prog...d-related.html
    Please read VBA Express' policy on Cross-Posting in Rule 3: http://www.vbaexpress.com/forum/faq...._new_faq_item3
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  5. #5
    VBAX Newbie
    Joined
    May 2021
    Location
    UK
    Posts
    4
    Location

    Great - solution found

    Quote Originally Posted by macropod View Post
    For x = 1 to 199
       ActiveDocument.Shapes("Picture" & x).Delete
    Next
    Yes, that worked perfectly. It's highlighted a different problem (for me) but the code worked like a charm. Thank you, I really appreciate it

Posting Permissions

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