Deprecated: Function ereg() is deprecated in /rscs/rs/websites/lmpx.com/code/nav/common.inc on line 99
Deprecated: Function ereg() is deprecated in /rscs/rs/websites/lmpx.com/code/nav/common.inc on line 82
Thanks. Also, which of the many online manuals would be my
best resource? I find myself trying one keyword after
another.
> OLEObject lole_object, xlsub
> .....
> your code
> TRY
> lole_object.Application.Workbooks.Open(is_fullpath )
> xlsub =
> lole_object.Application.ActiveWorkbook.Worksheets[1]
> CATCH (OLERuntimeError ole_err1)
> MessageBox(This.Title + "Excel Error", "An error
> occurred while opening the spreadsheet.~n" +
> string(ole_err1.description)) // Or whatever message you
> want
> END TRY
>
> ls_acctno = String(xlsub.Cells[2,1].Value)
>
> Should work... HTH KL
>
>
> > I just tried that and it is failing with the message
> > "Error calling external object function worksheets"
> >
> > There is only one worksheet in the Excel spreadsheet.
> >
> >
> >
> > > Try worksheets[is_worksheet]
> > > Do you have more than 1?
> > >
> > >
> > >
> > > HTH KL
> > > > I need some help in pulling an excel spreadsheet
> > > > into my application. I thought that I had an
> > > > example from another application, but similar
> > > > code is failing in my app.
> > > >
> > > > I have the following:
> > > >
> > > > datastore lds_import_history
> > > > lds_import_history = Create datastore
> > > > lds_import_history.DataObject = 'd_excel_data'
> > > > lds_import_history.SetTransobject( SQLCA )
> > > >
> > > >
> > > > // Create or "Instantiate" the ole_object variable
> > > > OLEObject lole_object
> > > > lole_object = CREATE OLEObject
> > > >
> > > >
> > > > // Fire the pre_import event
> > > > // Now try to connect to Excel
> > > > li_rc = lole_object.ConnectToNewObject(
> > > > "excel.application" )
> > > > IF li_rc <> 0 THEN
> > > > ls_errormsg = "Unable to start an OLE server
> > > > process!" ELSE
> > > > //
> > > >
> > > > // Attempt to not display alerts.
> > > > lole_object.Application.DisplayAlerts = FALSE
> > > > // Open the .xls file
> > > > lole_object.workbooks.Open( is_fullpath )
> > > > // Make Object Invisible
> > > > lole_object.Visible = FALSE
> > > >
> > > > // Get the account Number from the spreadsheet
> > > > ls_acctno = String(
> > > >
> > > >
> > >
> > > >
> >
> > > >
> lole_object.application.workbooks(1).worksheets(is_workshe
> > > > et).cells(2 ,1).value ) if isNull (ls_acctno) then
> > > > MessageBox("Required Field","No Account
> > > > Number Found") li_rc = -99 is_comments =
> > > > 'Account Number Found' Else
> > > > is_acctno = ls_acctno
> > > > End If
> > > > .
> > > > .
> > > > .
> > > > .
> > > > .
> > > > .
> > > > .
> > > > .
> > > > .
> > > > Most of this code is copied code
> > > > The Connect statement is working. At least, I get a
> > > > zero return code.
> > > > I don't get an error until I hit the line that tries
> > > > to actually retrieve a value from the spreadsheet.
> > > > The line that says ls_acctno =
> > > > At that point, I get "Error calling external object
> > > > function worksheets"
> > > >
> > > > I copied the dlls from the application that works,
> > > > so I don't know where to go from here. Is there any
> > > > way to discover what exactly is failing?
> > > >
> > > > On another note, I found the following code in the
> > > > forum. This one, when I try to use it--gets a
> > > > different error as soon as I
> > > > hit the activate statement.
> > > >
> > > > OLEObject excel
> > > >
> > > >
> > > > Integer li_RetValue, li_rtn
> > > > Boolean lb_sheet_rtn
> > > > Long ll_cnt
> > > >
> > > >
> > > > excel = create OLEObject
> > > >
> > > >
> > > > li_rtn =
> > > > excel.ConnectToNewObject("excel.application") IF
> > > > li_rtn <> 0 THEN MessageBox('Excel erro','can
> > > > not run Excel Program') DESTROY excel
> > > > RETURN 0
> > > > END IF
> > > >
> > > >
> > > > excel.WorkBooks.Open( as_path_and_filename )
> > > > excel.Application.Visible = false
> > > > excel.windowstate = 2 // 1 : Normal, 2 : Minimize, 3
> > > > : Maximize
> > > >
> > > >
> > > > lb_sheet_rtn = excel.worksheets(1).Activate
> > > > excel.Worksheets(1).Range(range).Copy // copy to
> > > > clipboard ll_cnt = dw.importclipboard()
|