Strange problem with win32 (WinWord Automotion).

vtail vtail at yandex.ru
Wed Aug 14 16:34:18 CEST 2002


Uups, this is not a problem with win32 - I've already discovered bug
in my example. The problem was that wdGoToHeading became zero again in
f2() - it was only local assignment in f1().

Thank you for your time, Victor.



vtail at yandex.ru (vtail) wrote in message news:<9ff6b66.0208140237.5fc0cbf1 at posting.google.com>...
> Greetings.
> 
> Can someone please help me with win32-related problem? I've following
> obvious test script:
> ----
> import win32com.client
> from win32com.client import Dispatch
> 
> wdGoToHeading = 0
> 
> def f1(filename):
>     W = Dispatch("Word.Application")
>     W.Visible = 0
>     wdGoToHeading = win32com.client.constants.wdGoToHeading
> 
>     W.Documents.Open(filename)
>     D = W.Documents[0]
>     R = D.Range()
>     print "R start & end", R.Start, R.End
>     R1 = R.GoTo(wdGoToHeading)
>     print "R1 start & end", R1.Start, R1.End
> 
>     f2(R)
> 
> def f2(R):
>     print "f2 R start & end", R.Start, R.End
>     R1 = R.GoTo(wdGoToHeading)
>     print "f2 R1 start & end", R1.Start, R1.End
> 
> if __name__=="__main__":
>     f1(r"o:\_public\_publishing\_mcomment\mc020821.doc")
> ----
> 
> and it returns following lines:
> 
> ----
> R start & end 0 41773
> R1 start & end 2617 2617
> f2 R start & end 0 41773
> f2 R1 start & end 0 0
> ----
> 
> - that looks quite strange. Do you have any ideas about it?
> 
> Thanks a lot, Victor.



More information about the Python-list mailing list