embed python in ms-word?

Gerhard Häring gh at ghaering.de
Sat Sep 6 04:50:02 EDT 2008


oyster wrote:
> In my ms-word documnet, there are some calculation whihc I have to
> change due to different argumnet. is there any way to embed python
> code in word, so that I can write the following as a macro or
> something else, then the result (i.e. 2) is shown in the word
> documnet?
> 
> def f(n):
>   if n<2:
>     return 1
>   else:
>     return f(n-1)+f(n-2)
> main()
>   return 'fib(3)=%0i' % f(3)
> 
> if that is impossible, does there exist such word-addons can do that? thanx

With Python and the win32 extensions you can write COM servers. These
you can use from Visual Basic for Applications (VBA).

But it's really only worth the effort if you're doing something less
trivial than above ;-)

-- Gerhard



More information about the Python-list mailing list