Ruby on Windows

Is there any good Ruby example that manipulate any Office Docoments,
especially the Access database?

As, I have an Access(dev db) Image Database, I’d like to be able to get the
information from Access(using Ruby), and manipulate them(e.g, resize the
image) and then put them in MySQL database(live db).

Thanks

Ruby Tuesday wrote:

Is there any good Ruby example that manipulate any Office Docoments,
especially the Access database?

As, I have an Access(dev db) Image Database, I’d like to be able
to get the
information from Access(using Ruby), and manipulate them(e.g, resize the
image) and then put them in MySQL database(live db).

I haven’t done this myself, but you probably want to take a look at Winole.
Here’s a good starting point:

http://www.rubygarden.org/ruby?RubyAndCOM

Curt

···

Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.610 / Virus Database: 390 - Release Date: 3/3/2004

“Ruby Tuesday” rubytuzdayz@yahoo.com writes:

Is there any good Ruby example that manipulate any Office Docoments,
especially the Access database?

As, I have an Access(dev db) Image Database, I’d like to be able to get the
information from Access(using Ruby), and manipulate them(e.g, resize the
image) and then put them in MySQL database(live db).
Have you tried some Ruby ODBC?
ODBC Binding for Ruby

Regards
Friedrich

Ruby Tuesday wrote:

Is there any good Ruby example that manipulate any Office
Docoments, especially the Access database?

For what it’s worth, I have been playing with the RubyScript WSH
scripting engine and from what I can tell the WSH Ruby code is a
lot like VB Script or Java Script.

For example consider these two code snipets:

This is Ruby Script:

def key_macro()
# create the speech object
oSpeech = WIN32OLE.new(“SAPI.SpVoice”)

# say something
oSpeech.Speak("The computer will talk...")

end

key_macro() # run the macro

This is VB Script:

Function key_macro()
’ create the speech object
Set oSpeech = CreateObject(“SAPI.SpVoice”)

' say something
oSpeech.Speak("The computer will talk...")

End Function

key_macro() 'run the macro

As can be seen from the code above, both scripts are
very similar.

This should mean that if you find a good VB Script or Java
Script example (of which there should be many), then it
should be a fairly easy task to port the code to RubyScript.

Jussi Jumppanen
Author of: Zeus for Windows (All new version 3.92 out now)
“The C/C++, Cobol, Java, HTML, Python, PHP, Perl programmer’s editor”
Home Page: http://www.zeusedit.com

“Ruby Tuesday” rubytuzdayz@yahoo.com wrote in message

Is there any good Ruby example that manipulate any Office Docoments,
especially the Access database?

This should get you started …

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:>cd atest

C:\atest>type tst_access.rb

require ‘win32ole’

MDB_FILE_NAME = “C:\Program Files\Microsoft
Office\Office10\Samples\Northwind.mdb”

Create the object

db=WIN32OLE.new(“ADODB.Connection”)

Set parameters

db.ConnectionString = “Provider=Microsoft.Jet.OLEDB.4.0;” +
“Data Source="#{MDB_FILE_NAME}"”

Open connection

db.open

Construct query string

sSQL = “select top 10 * from [Order Details]”

Execute Query

rs = db.Execute(sSQL)

Print first line of header

puts
n = 0
rs.fields.each do |field|
print "%10s " % [field.name]
n += 1
end
puts

Print second line of header

n.times{print "%10s " % [‘-’*10]}
puts

Fetch the first record

rs.MoveFirst if !rs.eof

Loop till no more records

while !rs.eof

Print each row

rs.fields.each do |field|
print "%10s " % [field.value]
end
puts

Fetch the next record

rs.MoveNext

end

Close connection

db.close

END

C:\atest>ruby -v tst_access.rb
ruby 1.8.1 (2004-01-27) [i386-mswin32]

OrderID ProductID UnitPrice Quantity Discount


 10248         11         14         12        0.0
 10248         42        9.8         10        0.0
 10248         72       34.8          5        0.0
 10249         14       18.6          9        0.0
 10249         51       42.4         40        0.0
 10250         41        7.7         10        0.0
 10250         51       42.4         35 0.150000005960464
 10250         65       16.8         15 0.150000005960464
 10251         22       16.8          6 0.0500000007450581
 10251         57       15.6         15 0.0500000007450581

C:\atest>

I will try each and find which one is easier to move my data in Access
database, Excell, and Word Table into
MySQL database.

Thanks, but please do post if you know more sites that gives a good tutorial
or sample code. Thanks

“Ruby Tuesday” rubytuzdayz@yahoo.com wrote in message
news:c49f8v$2egqdo$1@ID-205437.news.uni-berlin.de

Is there any good Ruby example that manipulate any Office Docoments,
especially the Access database?

As, I have an Access(dev db) Image Database, I’d like to be able to get
the

···

information from Access(using Ruby), and manipulate them(e.g, resize the
image) and then put them in MySQL database(live db).

Thanks

A tutorial for accessing MS Word:

http://www.testing.com/writings/bypassing-the-gui.pdf

···

At 02:09 PM 3/31/2004, Ruby Tuesday wrote:

Thanks, but please do post if you know more sites that gives a good tutorial
or sample code. Thanks


Bret Pettichord, Software Tester
Consultant - www.pettichord.com
Author - www.testinglessons.com
Blogger - www.io.com/~wazmo/blog

Homebrew Automation Seminar
April 30, Austin, Texas
www.pettichord.com/training.html