Pythonwin - Word automation - Removing watermark not working

Gregory Piñero gregpinero at gmail.com
Thu Nov 3 19:55:08 EST 2005


I thought I'd take a shot and see if anyone knows the answer to this? I've
been stuck for a while now on this.

Would anyone happen to know why this my function removewatermark() in this
code isn't working? I copied it from a Word macro I recorded and it did work
when I recorded the macro. When I run it the watermark doesn't go away.

I've also attached the code in case the formatting gets messed up from the
email.


<code>
import sys
import os
from win32com.client import gencache, constants
WORD='Word.Application'
False,True=0,-1

class Word:
def __init__(self):
self.app=gencache.EnsureDispatch(WORD)
self.app.Visible = 1
self.app.DisplayAlerts = 0
def open(self,doc):
self.app.Documents.Open(FileName=doc)
def removewatermark(self):
self.app.ActiveDocument.Sections(1).Range.Select()
self.app.ActiveWindow.ActivePane.View.SeekView = 9 # wdSeekCurrentPageHeader
self.app.Selection.HeaderFooter.Shapes("PowerPlusWaterMarkObject1").Select()
self.app.Selection.Delete()
self.app.ActiveWindow.ActivePane.View.SeekView = 0 #wdSeekMainDocument
</code>


Thanks,

Greg

--
Gregory Piñero
Chief Innovation Officer
Blended Technologies
(www.blendedtechnologies.com <http://www.blendedtechnologies.com>)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20051103/ad41e0aa/attachment.html>
-------------- next part --------------
import sys
import os
from win32com.client import gencache, constants
WORD='Word.Application'
False,True=0,-1

class Word:
    def __init__(self):
        self.app=gencache.EnsureDispatch(WORD)
        self.app.Visible = 1
        self.app.DisplayAlerts = 0
    def open(self,doc):
        self.app.Documents.Open(FileName=doc) 
    def removewatermark(self):
        self.app.ActiveDocument.Sections(1).Range.Select()
        self.app.ActiveWindow.ActivePane.View.SeekView = 9 # wdSeekCurrentPageHeader
        self.app.Selection.HeaderFooter.Shapes("PowerPlusWaterMarkObject1").Select()
        self.app.Selection.Delete()
        self.app.ActiveWindow.ActivePane.View.SeekView = 0 #wdSeekMainDocument 


More information about the Python-list mailing list