Someone there suggested I try this group instead. Any help or suggestions would be greatly appriciated.
Thanks,
-Greg
---------- Forwarded message ----------
From: Gregory Piñero <[EMAIL PROTECTED]>
Date: Nov 3, 2005 7:55 PM
Subject: Pythonwin - Word automation - Removing watermark not working
To: python-list@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 )
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
_______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32