Re: embed python in ms-word?
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 n2: 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: embed python in ms-word?
in fact, during my work, I often write documnets in ms-word. But the doc has many numbers in it, which need to be calculated and to be modified frequently. Is there a method to write a ms-word add-in, so that 1.I can type in the calculation steps in some program language, please have a look at http://blender.bokee.com/inc/word_add_in1.jpg 2.then the result (here, it is 8) is shown in the doc when I close this window? please have a look at http://blender.bokee.com/inc/word_add_in2.jpg 3.when I double-click the result 8, I can view/edit the code again 4.the code for calculation is stored in DOC file too, I can change it later mathtype equation is a kind of such thing, but only for displaying nice equation I don't think vba is a good answer, the main reason is: the vba code has an incompact link with its result in the documnet -- http://mail.python.org/mailman/listinfo/python-list
Re: embed python in ms-word?
oyster schrieb: in fact, during my work, I often write documnets in ms-word. But the doc has many numbers in it, which need to be calculated and to be modified frequently. Is there a method to write a ms-word add-in, so that 1.I can type in the calculation steps in some program language, please have a look at http://blender.bokee.com/inc/word_add_in1.jpg 2.then the result (here, it is 8) is shown in the doc when I close this window? please have a look at http://blender.bokee.com/inc/word_add_in2.jpg 3.when I double-click the result 8, I can view/edit the code again 4.the code for calculation is stored in DOC file too, I can change it later mathtype equation is a kind of such thing, but only for displaying nice equation I don't think vba is a good answer, the main reason is: the vba code has an incompact link with its result in the documnet I don't know what you mean with the last sentence - but I still think VBA is the answer. There is no other way to write a plugin or some such for word than using COM, and VB *is* COM. So whatever you can do in Word, it's exposed in VBA. Bringing python into the mixture is just creating a lot of hassle. Automating word with Python is a different thing - that seems to be popular and powerful. Diez -- http://mail.python.org/mailman/listinfo/python-list
embed python in ms-word?
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 n2: 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 -- http://mail.python.org/mailman/listinfo/python-list