[python-win32] Pythonwin - Word automation - Removing watermark not working
Gregory Piñero
gregpinero at gmail.com
Sat Nov 5 18:29:56 CET 2005
Hi everybody. I originally sent this question to the main Python list to
have it be met with roaring silence ;-)
Someone there suggested I try this group instead. Any help or suggestions
would be greatly appriciated.
Thanks,
-Greg
---------- Forwarded message ----------
From: Gregory Piñero <gregpinero at gmail.com>
Date: Nov 3, 2005 7:55 PM
Subject: Pythonwin - Word automation - Removing watermark not working
To: python-list at python.org
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-win32/attachments/20051105/57548658/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-win32
mailing list