Backslash is the 'escaping' character in ruby, for example to insert
a single quote as part of a single quoted string you would do
s='that\'s the answer'
If you : puts s
you would get: that's the answer
Similarly it would be used to insert a double-quote inside a double
quoted string.
So the end result is that \ is always seen as an escaping charcter, no
matter what kind of quotes you are enclosing the string in.
To get a single \ inside a string you need to double it
try
excel.Workbooks.Open('D:\\shiv.xls')
reading this might help your understanding,
http://www.ruby-forum.com/topic/130674
On Jul 8, 8:12 am, Shiv <
tms...@gmail.com> wrote:
> sorry,I did not get you...because what you are suggesting already exists..I
> mean my excel file shiv.xls is already in D-drive, I have used single
> quotes..you want me to use double quotes ? I have already done that it
> doesnt help
>
>
>
> On Thu, Jul 8, 2010 at 7:11 PM, SMF SMF <
shaikm.fi...@gmail.com> wrote:
> > excel.Workbooks.Open(''D:\shiv.xls'') - change this line also and make
> > shiv.xls exist in D-drive
>
> > On Thu, Jul 8, 2010 at 6:55 PM, Basim Baassiri <
ba...@baassiri.ca> wrote:
>
> >> is the d drive that you are specifying a network share? also, does the
> >> file exist with the correct spelling
>
> >> Basim
>
> >> On Thu, Jul 8, 2010 at 8:08 AM, Shiv <
tms...@gmail.com> wrote:
>
> >>> Thanks, BUT i get same error, I changed the 2nd line to
>
> >>> excel = WIN32OLE::new('excel.application')
> >>> On Thu, Jul 8, 2010 at 5:09 PM, SMF SMF <
shaikm.fi...@gmail.com>wrote:
>
> >>>> Change 2nd line to as below-
>
> >>>> excel = WIN32OLE::new('excel.application')
>
> >>>> On Thu, Jul 8, 2010 at 5:00 PM, Shiv <
tms...@gmail.com> wrote:
>
> >>>>> Hello,
>
> >>>>> I am trying to open a excel file and write data, but i m getting
> >>>>> runtime error
> >>>>> I checked the path is correct
> >>>>> new method works fine but open method throws error...can u pls help me
> >>>>> figure out this problem
>
> >>>>> *Code:*
> >>>>> require 'win32ole'
> >>>>> excel = WIN32OLE.new('excel.application')
> >>>>> excel.visible = true
> >>>>> excel.Workbooks.Open('D:\shiv.xls')
> >>>>> excel.range('A1').value = 'Hello, world.'
> >>>>> excel.Close
> >>>>> excel.Quit
>
> >>>>> *Error:*
> >>>>> C:\Ruby\bin>ruby C:\Ruby_Scripts\Ex_open.rb
> >>>>> C:/Ruby_Scripts/Ex_open.rb:6:in `method_missing': Open
> >>>>> (WIN32OLERuntimeError)
> >>>>> OLE error code:800A03EC in Microsoft Office Excel
> >>>>> 'D:\shiv.xls' could not be found. Check the spelling of the file
> >>>>> name, and
> >>>>> verify that the file location is correct.
> >>>>> If you are trying to open the file from your list of most recently used
> >>>>> files, m
> >>>>> ake sure that the file has not been renamed, moved, or deleted.
> >>>>> HRESULT error code:0x80020009
> >>>>> Exception occurred.
> >>>>> from C:/Ruby_Scripts/Ex_open.rb:6
>
> >>>>> Regards,
> >>>>> Shiv
>
> >>>>> --
> >>>>> Before posting, please readhttp://
watir.com/support. In short: search
> >>>>> To unsubscribe:
watir-genera...@googlegroups.com<watir-general%2Bunsubscribe@goog
legroups.com>
>
> >>>> --
> >>>> Before posting, please readhttp://
watir.com/support. In short: search
> >>>> To unsubscribe:
watir-genera...@googlegroups.com<watir-general%2Bunsubscribe@goog
legroups.com>
>
> >>> --
> >>> Before posting, please readhttp://
watir.com/support. In short: search
> >>> To unsubscribe:
watir-genera...@googlegroups.com<watir-general%2Bunsubscribe@goog
legroups.com>
>
> >> --
> >> Before posting, please readhttp://
watir.com/support. In short: search
> >> To unsubscribe:
watir-genera...@googlegroups.com<watir-general%2Bunsubscribe@goog
legroups.com>
>
> > --
> > Before posting, please readhttp://
watir.com/support. In short: search
> > To unsubscribe:
watir-genera...@googlegroups.com<watir-general%2Bunsubscribe@goog
legroups.com>- Hide quoted text -
>
> - Show quoted text -