Hi chuck,
Thx for the info
I have done what you have suggested but it doesn't help. I get same error
my script fails in the second line itself, I get a runtime error from
WINN32OLE...is it something to do with watir version I am using?
my watir version is watir-1.6.5
require 'win32ole'
excel = WIN32OLE::new('excel.application')
excel.visible = true
wb = excel.Workbooks.Open('D:\\shiv.xls')
Shiv
On Thu, Jul 8, 2010 at 9:22 PM, Chuck van der Linden <[email protected]>wrote:
> 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 <[email protected]> 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 <[email protected]> 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 <[email protected]>
> 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 <[email protected]> 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 <[email protected]
> >wrote:
> >
> > >>>> Change 2nd line to as below-
> >
> > >>>> excel = WIN32OLE::new('excel.application')
> >
> > >>>> On Thu, Jul 8, 2010 at 5:00 PM, Shiv <[email protected]> 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
> > >>>>> before you ask, be nice.
> >
> > >>>>> You received this message because you are subscribed to
> > >>>>>http://groups.google.com/group/watir-general
> > >>>>> To post: [email protected]
> > >>>>> To unsubscribe:
> > >>>>> [email protected]<watir-general%[email protected]>
> <watir-general%2bunsubscr...@googlegroups.com>
> >
> > >>>> --
> > >>>> Before posting, please readhttp://watir.com/support. In short:
> search
> > >>>> before you ask, be nice.
> >
> > >>>> You received this message because you are subscribed to
> > >>>>http://groups.google.com/group/watir-general
> > >>>> To post: [email protected]
> > >>>> To unsubscribe:
> > >>>> [email protected]<watir-general%[email protected]>
> <watir-general%2bunsubscr...@googlegroups.com>
> >
> > >>> --
> > >>> Before posting, please readhttp://watir.com/support. In short:
> search
> > >>> before you ask, be nice.
> >
> > >>> You received this message because you are subscribed to
> > >>>http://groups.google.com/group/watir-general
> > >>> To post: [email protected]
> > >>> To unsubscribe:
> > >>> [email protected]<watir-general%[email protected]>
> <watir-general%2bunsubscr...@googlegroups.com>
> >
> > >> --
> > >> Before posting, please readhttp://watir.com/support. In short: search
> > >> before you ask, be nice.
> >
> > >> You received this message because you are subscribed to
> > >>http://groups.google.com/group/watir-general
> > >> To post: [email protected]
> > >> To unsubscribe:
> > >> [email protected]<watir-general%[email protected]>
> <watir-general%2bunsubscr...@googlegroups.com>
> >
> > > --
> > > Before posting, please readhttp://watir.com/support. In short: search
> > > before you ask, be nice.
> >
> > > You received this message because you are subscribed to
> > >http://groups.google.com/group/watir-general
> > > To post: [email protected]
> > > To unsubscribe:
> > > [email protected]<watir-general%[email protected]>
> <watir-general%2bunsubscr...@googlegroups.com>- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> Before posting, please read http://watir.com/support. In short: search
> before you ask, be nice.
>
> You received this message because you are subscribed to
> http://groups.google.com/group/watir-general
> To post: [email protected]
> To unsubscribe:
> [email protected]<watir-general%[email protected]>
>
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
You received this message because you are subscribed to
http://groups.google.com/group/watir-general
To post: [email protected]
To unsubscribe: [email protected]