Strange problem with win32 (WinWord Automotion).
GerritM
gmuller at worldonline.nl
Wed Aug 14 10:00:39 EDT 2002
"vtail" <vtail at yandex.ru> schreef in bericht
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.
In f1 you use wdGoToHeading defined within that function, in f2 you use
wdGoToHeading defined to be 0 in line 4 ??
I did not check with the namespace rules, but I would make explicit which
wdGoToheading f2 is using.
regards Gerrit
--
www.extra.research.philips.com/natlab/sysarch/
More information about the Python-list
mailing list