embed python in ms-word?

O

oyster

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
 
G

Gerhard Häring

oyster said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top