WIN32OLE & MS Access 2007: read-only... only?

Hi,

With Office 2003, I am able to open through ruby an Access database,
make a few structure changes in it, and finally open a report, with code
similar to:

require ‘win32ole’
access = WIN32OLE.new(‘Access.Application’)
database = File.expand_path(’<the_msaccess_database_name>)
access.OpenCurrentDatabase(database)
access.run("<the_msaccess_public_sub_in_vbs>", “param1”, “param2”)
access.DoCmd.OpenReport(“the_msaccess_report”, 2, “”, “”)
access.Visible = true

This works fine with both the old Ruby O.-Click Installer 1.8.6, and
the upcoming Ruby Installer 1.8.6 RC2, from Luis L…

Unfortunately, things are getting worse with Office 2007. For an unknown
reason, database is opened read-only, and the command

access.run("<the_msaccess_public_sub_in_vbs>", “param1”, “param2”)

… fails, since it tries to modify the structure (a querydef in fact)
of a read-only database.

Strangely, this almost similar code rewritten in wsh:

Set objAcc = WScript.CreateObject(“Access.Application”)
strDBName = “<the_msaccess_database_path>”
objAcc.OpenCurrentDatabase strDBName
objAcc.run “<the_msaccess_public_sub_in_vbs>”, ", “param1”, “param2”
objAcc.DoCmd.OpenReport “the_msaccess_report”, 2, “”, “”
objAcc.Visible = true

… works perfectly. Access 2007 database is opened read-write, and
scripts executes fine.

I’m not sure who is the culprit here: Ruby/WIN32OLE? Not really, it
works fine with Office 2003. Office 2007? Hum, maybe, but it works
through WSH…

Does anyone have an idea maybe?

Best regards,

access.run("<the_msaccess_public_sub_in_vbs>", “param1”, “param2”)

objAcc.Visible = true

… works perfectly. Access 2007 database is opened read-write, and
scripts executes fine.

I’m not sure who is the culprit here: Ruby/WIN32OLE? Not really, it
works fine with Office 2003. Office 2007? Hum, maybe, but it works
through WSH…

Does anyone have an idea maybe?

One more precision: with this VBScript code, integrated into an HTML
file, database is opened read-write too. Only the ruby code opens the
database read-only…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs