PDA

View Full Version : [SOLVED:] Easy one to get started



bremhillbob
05-07-2021, 01:02 AM
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?

SamT
05-07-2021, 06:45 AM
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

macropod
05-07-2021, 01:54 PM
For x = 1 to 199
ActiveDocument.Shapes("Picture" & x).Delete
Next

macropod
05-07-2021, 02:14 PM
Cross-posted at: https://www.excelforum.com/word-programming-vba-macros/1348902-simple-vba-question-but-word-related.html
Please read VBA Express' policy on Cross-Posting in Rule 3: http://www.vbaexpress.com/forum/faq.php?faq=new_faq_item#faq_new_faq_item3

bremhillbob
05-08-2021, 05:14 AM
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