<div dir="ltr">On Tue, Oct 14, 2008 at 9:23 AM, URBAN LANDREMAN <span dir="ltr"><<a href="mailto:ulandreman@msn.com">ulandreman@msn.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div style="text-align: left;">Thanks for the suggestion.<br><br>When I ran the slightly modified code:<br>import win32com.client<br>app = win32com.client.Dispatch('Word.Application')<br>docOrig = app.Documents.Open('n:\\MetroPlanners\\2006\\MCHResearchProject.doc')<br>
range = docOrig.Content()<br>range.Find.Text = "e"<br>range.Find.Replacement.Text = "*"<br>range.Find.Execute()<br>docEditted = doc<br>docEditted.SaveAs('n:\\MetroPlanners\\2006\\MCHResearchProjectV2.doc')<br>
app.Quit()<br><br><br>I got:<br><br>Traceback (most recent call last):<br> File "N:/SPSS/Python/Examples/MSWord/WordFindAndReplaceV2", line 5, in <module><br> range.Find.Text = "e"<br>AttributeError: 'unicode' object has no attribute 'Find'<br>
</div></div></blockquote><div><br>docOrig.Content() returns you a Unicode object, which isn't the same as a Word document at all. You're then trying to use methods on that object which aren't supported. I can't give you specifics without doing a bit of Googling myself, but you probably want a different call on line 4 to give you an object you can work with.<br>
<br></div></div><br>-- <br><a href="http://www.fsrtechnologies.com">www.fsrtechnologies.com</a><br>
</div>