Windows ole word automatism / use JUNO

JohnC johnch_atms at hotmail.com
Tue Nov 14 15:00:19 PST 2006


"BLS" <Killing_Zoe at web.de> wrote in message 
news:ejd1g9$2g0c$1 at digitaldaemon.com...
> Hi Gregor,
> Have a look at the dmd samples directory. dclient.d
> As far as I can see your ruby sample is a typical late binding scenario.
> D can do more, or, in other words  D can do what C++ can do, but in a 
> readable way. Have a look at the JUNO tool chain at dsource.org ... 
> projects JUNO.
> Björn // btw : dsource is not avail. at the moment.
>
>
> Gregor Kopp schrieb:
>> Hi guys !
>>
>> I'm fresh to D and really happy about the easy syntax compared to C++.
>> I would like to do automation with winword on my job here.
>>
>> First of all, a little Ruby code, so that you can see what I mean:
>>
>> Code starts here:
>>
>> require "win32ole"
>> @word = WIN32OLE.new('Word.Application') # initialize a new word
>> # next line: create a new file with the given template
>> @word.documents.add(File.expand_path("myownfiletemplate.dot"))
>> # next line: show word, because it would be hidden!
>> @word.Visible = 1
>> # search for text
>> @word.selection.find.text = "Text to Search"
>> @word.selection.find.execute
>> # after search (text will me marked) exchange "Text to Search" with
>> # "Replaced by this Text"
>> @word.selection.typetext "Replaced by this Text"
>>
>> Code ends here
>>
>>
>>
>> Das a similiar lib (like this win32ole lib from ruby) exist for the D 
>> language? I also tried to work with dfl it does have a module named 
>> dfl.wincom, but there is no usable documentation about it, and I really 
>> don't know if its the right module.
>>
>> Greets, Gregor

You're better off using early binding than late binding. It's faster and a 
lot easier to use. You'll first need to translate the msword.olb type 
library to a D module. Tlbimpd should help you with that (look for Juno on 
DSource). Or use OleView and do it by hand. 





More information about the Digitalmars-d mailing list