View Single Post
  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman
 
Posts: n/a
Default macro produces error message

"Selection.HeaderFooter.Shapes("Shape1").Select ."

That is _not_ what Cindy told you to try. When you put "Shape1" in
quotes in the parentheses, that's telling VBA to look for a shape that
is literally named "Shape1". There obviously isn't any such shape.

What Cindy suggested should be written in full as

Selection.HeaderFooter.Shapes(1).Select

which refers to the first shape in the header, regardless of what its
name is.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Thu, 9 Mar 2006 10:00:29 -0800, Kimmie B
wrote:

Thanks for the response Cindy. While your idea makes sense, in reality it
didn't work.

I changed the VB script to indicate
"Selection.HeaderFooter.Shapes("Shape1").Select ." and got the same error
message.

Is there a way to know the object name for Word 2003's DRAFT watermark? If
so, I'll see if I can manipulate the VB script to find it.

Alternatively, can anyone provide me with a macro that works for removing a
DRAFT watermark?

Thanks,

Kimmie

"Cindy M -WordMVP-" wrote:

Hi ?B?S2ltbWllIEI=?=,

I'm trying to create a macro on a template that automatically removes the
DRAFT watermark from the document, and I want to add a button for this new
macro to the custom toolbar that already exists in the template.

Per Word online Help, I've tried Tools Macro Record New Macro, and
clicked the toolbar icon and recorded the steps for removig the watermark.

When I record the macro, the watermark disappears, as I expect it to.
However, when I later add the watermark back in to test the macro, and try to
use the button, I get a runtime error message ("the item with the specified
name wasn't found"). When I click the debug button, VB indicates the
following faulty code:
Selection.HeaderFooter.Shapes("PowerPlusWaterMarkO bject2").Select.

Well... Every Shape (graphic object with text-flow formatting applied) has a
name. In the case of the macro you recorded, the name of the Shape (watermark)
was "PowerPlusWaterMarkObject2". The watermark you inserted later probably had a
different name, which is why you get the error message.

If you plan to be recreating/deleting the watermark, then you either have to
include giving it a name when it's created...

OR you have to specify it in a different manner. If this is the only graphic
object in the Header/Footer, try using Shapes(1) instead of the name.

Also, the new macro does not appear when I select Tools Macro on the menu
bar.

Not sure what the problem is, here. But macros can be stored in Normal.dot, in
the individual document on which you're working, that document's attached
template, or any global template. If you've saved the macro in one place, and
then selected something different from the "Macros in" list in this dialog box,
you may not see it in the list until you change this selection.

Ideally, I'd like a macro button that lets the user toggle between having
the DRAFT watermark turned on and off, but right now I'd just settle for a
button that works properly to turn off the draft watermark.


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)