Group:  Microsoft Word ยป microsoft.public.word.vba.beginners
Thread: Best way to work with a Word doc in another language, WAS: Accessing Python or DLLs from Word

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Best way to work with a Word doc in another language, WAS: Accessing Python or DLLs from Word
"Goran" <goran[ at ]bokverket.com> 05.03.2006 10:24:32
I wrote:
I am experimenting with an app which is to process large Word doc's, and
needs the dictionary objects available in Python (and C++).Jezebiel wrote:

Jezebiel answered.
Don't know anything about Python. You can register a DLL (or any compliant
library file) in VBA through Tools > References. The functions within the
DLL can then be called from within VBA. They don't appear directly as
macros. You need to write wrapper functions (ie a macro that calls the DLL
function).

Thanks much. I wonder if both the following skeleton code ideas are
possible; and if there is a large overhead for each access to Word in the
first one which gets one word at a time.

'*** First idea
VBA Wrapper:
StartDLL(pointertocurrentWordDocument)

Inside DLL:
Word.getNextWord(pointertocurrentWordDocument) until endofdoc
// Do whatever processing is needed


'*** Second idea
VBA Wrapper:
StartDLL(currentWordDocument) ' i.e. throw over the whole document right
away

Inside DLL:
currentWordDocument.processWord until endofdoc

Best,

Goran

(This is a re-send since I didn't manage to give the previous one a subject
line)


Re: Best way to work with a Word doc in another language, WAS: Accessing Python or DLLs from Word
"Oliver Townshend" <oliveratzipdotcomdotau> 05.03.2006 11:30:17
[Quoted Text]
> I am experimenting with an app which is to process large Word doc's, and
> needs the dictionary objects available in Python (and C++).Jezebiel wrote:

Don't know much about Python. A Google search reveals the following useful
link http://www.bstpierre.org/Projects/msword.py which may be helpful.

> Thanks much. I wonder if both the following skeleton code ideas are
> possible; and if there is a large overhead for each access to Word in the
> first one which gets one word at a time.

Doing it from inside Word might work. Alternative would be to open the word
document from inside python, and read through the activedocument structure,
pulling in words and then closing the document. Generally you'll want to
read up on the stuff at the msdn site and the like which has examples in C#
and VBA, and convert these to python. All you need are the type library
definitions in Word.

Oliver Townshend


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net