Actually this method won't work. The problem is that File.join will join 
the elements using a forward slash (/). The pathname is being passed to 
Excel, which truly requires that backslashes be used in the filename. 
I've argued that this is a bug in Ruby, but there it is.


LFIdnl wrote:
> More useful
> File.join($drive,env,"Test_Results","#{$file_name}_Results.xls" )
> On 17 дек, 00:20, "Darin Duphorn" <> wrote:
>> Try \\
>> $drive+"\\"+env+"\\Test_Results\\"+$file_name+"_Results.xls"
>> -----Original Message-----
>> From:
>> [] On Behalf Of
>> Sent: Tuesday, December 16, 2008 3:08 PM
>> To: Watir General
>> Subject: [wtr-general] Opening an Excel file with a variable name
>> All,
>> I am attempting to open an Excel file with Ruby, and have run into a
>> problem.  If I open the file with single quotes, like  inputFile =
>> input.Workbooks.Open('C:\Folder\sheet.xls') everything works fine.  My
>> problem now is that the location of the .xls file has a variable name,
>> like inputFile = input.Workbooks.Open("C:\#{var)\sheet.xls").  When I
>> try this, I get an error saying that the file cannot be found.  It
>> seems that the 'open' method will only work with single quotes, but to
>> signify a variable in a string in Ruby you have to use double quotes.
>> Has anyone discovered a way around this?  Thanks in advance for any
>> help.
>> - Shelton
> >

You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to
Before posting, please read the following guidelines:
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to