How to Run an Excel MACro from Ruby

How do I run an Excel macro from Ruby?

All you need to provide the OLE module is the macro name

excel.run('WriteToA1')

Also note, if you want to run a macro with an arguement, you use:

excel.run('MarcoWithArgs', "Arg")

Run ruby script through vba

The comment section made it clear: fully qualify your parameters, if they are files, and the files are not in the same directory as your Excel sheet.

Shell("ruby C:\Folder\dostuff.rb C:\Folder\file1.csv C:\Folder\file2.csv", vbNormalFocus)

Matlab doesn't run Excel macro

Okay the problem came from this line ExcelApp.Run("ThisWorkbook.hello"); and I needed to write ExcelApp.Run('hello'); instead.

So ThisWorkbook didn't work as well as the double quote.

Ruby Sketchup, get a value from an open excel workbook

Use this way

excel = WIN32OLE.connect("excel.application")
workbook = excel.Workbooks('workbook name')
worksheet = workbook.Worksheets('Sheet1')

Unexpected behavior using the run method for win32ole excel object

The syntax to pass an argument to a VBA macro seems to be

excel.run('Itakeargs', '1')

Still, the observed (and reproducable) behaviour is somewhat strange.



Related Topics



Leave a reply



Submit