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)
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
-- http://mail.python.org/mailman/listinfo/python-list