Adding a Hyperlink to an Excel spreadsheet from Ruby Importing Excel Constants values into Ruby
Nov 25

I noticed in my last entry that I used a function that I didn’t describe.  When sending filenames to applications like Excel 2007 or Word 2007, they are expecting the path to use the backslash ‘\’ character, rather than the Ruby default of a forwardslash ‘/’ that is returned from the DIR class. Older versions of Excel or Word don’t seem to care as they accept either one.  But to be safe, I always use this built-in function from the Windows Scripting engine to make sure my paths are correct.

require 'win32ole'

def getAbsolutePathName(file)
   fso ='Scripting.FileSystemObject') # VBA File System commands
   return fso.GetAbsolutePathName(file)
SociBook Digg Facebook Google Yahoo Buzz StumbleUpon

One Response to “Correct file paths for WIN32OLE applications in Ruby”

  1. Automating Visio with Ruby | / Says:

    [...] function to format the directory path to something Visio does like. I covered this function in a previous post. This file save is an ‘Extended’ form that saves the workspace (VisSaveAsWS) and also [...]

Leave a Reply