OLE Automation to Excel problem

Hello All,
In a report program I have used the OLE2 automation to download data into Excel. But it's not functioning. Its doing nothing. Could you tell me do I have to have any authorizations to use this? Otherwise what could be the problem?
Plz advise.
Thanks a lot.

Thnx Rich.
Here's the code:
<b>REPORT ZMR_MAX_PERIOD.
*-- Tables----
tables: mara,                           "General Material Data
        marc,                           "Plant Data for Material
        makt.                           "Material Descriptions
*-- Data of OLE
include ole2incl.
data: GS_EXCEL type ole2_object,
      GS_BOOKS type ole2_object,
      GS_WBOOK type ole2_object,
      GS_SHEET type ole2_object,
      GS_PAGE  type ole2_object,
      GS_RANGE type ole2_object,
      GS_FONT  type ole2_object,
      GS_COLS  type ole2_object,
      GS_CELL  type ole2_object.
*-- Variables----
*-- Offsets for output columns
data:      w_wid01   type i,
           w_wid02   type i,
           w_wid03   type i,
           w_wid04   type i,
           w_wid05   type i,
           w_wid06   type i,
           w_wid07   type i,
           w_wid08   type i,
           w_wid09   type i,
           w_wid10   type i,
           w_wid11   type i,
           w_wid12   type i,
           w_wid13   type i,
           w_wid14   type i,
           w_wid15   type i,
           w_wid16   type i,
           w_wid17   type i,
           w_color(1).                  "for background color
*-- Constants----
*-- Column widths for report output
constants: c_space   type i value  0,
           c_wid01   type i value  1,
           c_wid02   type i value  6,
           c_wid03   type i value  1,
           c_wid04   type i value 15,
           c_wid05   type i value  1,
           c_wid06   type i value 19,
           c_wid07   type i value  1,
           c_wid08   type i value 42,
           c_wid09   type i value  1,
           c_wid10   type i value 21,
           c_wid11   type i value  1,
           c_wid12   type i value 10,
           c_wid13   type i value  1,
           c_wid14   type i value 12,
           c_wid15   type i value  1,
           c_wid16   type i value 17,
           c_wid17   type i value  1.
*-- Internal tables----
*-- Internal table for material data
data: begin of i_material occurs 0,
        matnr like mara-matnr,
        mtart like mara-mtart,
        aenam like mara-aenam,
        laeda like mara-laeda,
        werks like marc-werks,
        maxlz like marc-maxlz,
        lzeih like marc-lzeih,
        maktx like makt-maktx,
      end of i_material.
*-- Internal table for output
data: begin of i_output occurs 0,
       werks like marc-werks,           "Plant
       mtart like mara-mtart,           "Material type
       matnr like mara-matnr,           "Material number
       maktx like makt-maktx,           "Material description
       maxlz like marc-maxlz,           "Maximum storage period
       lzeih like marc-lzeih,           "Unit for maximum storage period
       aenam like mara-aenam,           "User changed the object
       laeda like mara-laeda,           "Last changed on
     end of i_output.
SELECTION-SCREEN DEFINITION
*-- Data Selection
selection-screen begin of block b1 with frame title title1.
select-options: s_matnr for mara-matnr,
                s_werks for marc-werks,
                s_lgpro for marc-lgpro,
                s_mtart for mara-mtart.
selection-screen end of block b1.
AT SELECTION-SCREEN VALIDATIONS
at selection-screen.
*--Check Plant is entered
if s_werks is initial.
message e009(zm) with 'please enter plant'.
endif.
INITIALIZATION
initialization.
*-- initialize text fields for selection-screen
  title1 = 'Material Data'.
  title2 = 'File locations'.
  perform assign_column_widths.
START-OF-SELECTION (Required in 4.6)
start-of-selection.
  set pf-status 'MAIN'.
*-- Perform get data
  perform get_data.
*-- Populate data into output tab
  perform populate_data.
*-- Write output list
  perform write_output.
END-OF-SELECTION
TOP-OF-PAGE
TOP OF PAGE AT LINE SELECTION
AT LINE SELECTION
AT USER COMMAND
at user-command.
*-- Download to Excel
   case sy-ucomm.
     when 'EXCEL'.
      perform download_to_excel.
   endcase.
--S-U-B-R-O-U-T-I-N-E-S--
    FORM SET_BACKGROND_COLOR
Set background color for list output
form set_background_color.
  if w_color = 1.
     FORMAT INTENSIFIED OFF COLOR 2.
     clear w_color.
  else.
     FORMAT INTENSIFIED ON COLOR 2.
     w_color = 1.
  endif.
endform.                           "set_background_color
    FORM GET_DATA
Get material data
form get_data.
  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
   EXPORTING
     TEXT             = 'reading material data... '
    select mara~matnr
           mara~mtart
           mara~aenam
           mara~laeda
           marc~werks
           marc~maxlz
           marc~lzeih
           makt~maktx
      into table i_material
      from mara
      join marc
        on maramatnr = marcmatnr
      join makt
        on marcmatnr = maktmatnr
     where mara~matnr IN s_matnr
       and marc~werks IN s_werks
       and marc~lgpro IN s_lgpro
       and mara~mtart IN s_mtart.
    sort i_material by matnr.
endform.                           "get_data
    FORM POPULATE_DATA
Populate data for output
form populate_data.
  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
   EXPORTING
     TEXT             = 'Processing data... '
loop at i_material.
   move i_material-werks to i_output-werks.
   move i_material-mtart to i_output-mtart.
   move i_material-matnr to i_output-matnr.
   move i_material-maktx to i_output-maktx.
   move i_material-maxlz to i_output-maxlz.
   move i_material-lzeih to i_output-lzeih.
   move i_material-aenam to i_output-aenam.
   move i_material-laeda to i_output-laeda.
   append i_output.
   clear  i_output.
endloop.
sort i_output by matnr.
endform.                           "populate_data
    FORM WRITE_COLUMN_HEADINGS
Write column headings for output
form write_column_headings.
  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
   EXPORTING
     TEXT             = 'Writing output... '
   if i_output[] is initial.
     message i000.
     exit.
   endif.
*-- Write column headings
skip.
uline.
FORMAT COLOR 1 ON.
write: at /w_wid01 sy-vline.
write: at /w_wid02(c_wid02) 'Plant' CENTERED,
       at  w_wid03(c_wid03) SY-VLINE,
       at  w_wid04(c_wid04) 'Material Type' CENTERED,
       at  w_wid05(c_wid05) SY-VLINE,
       at  w_wid06(c_wid06) 'Material Number' CENTERED,
       at  w_wid07(c_wid07) SY-VLINE,
       at  w_wid08(c_wid08) 'Material Description' CENTERED,
       at  w_wid09(c_wid09) SY-VLINE,
       at  w_wid10(c_wid10) 'Max. Storage Period' CENTERED,
       at  w_wid11(c_wid11) SY-VLINE,
       at  w_wid12(c_wid12) 'Time Unit' CENTERED,
       at  w_wid13(c_wid13) SY-VLINE,
       at  w_wid14(c_wid14) 'Changed By' CENTERED,
       at  w_wid15(c_wid15) SY-VLINE,
       at  w_wid16(c_wid16) 'Last Changed On' CENTERED,
       at  w_wid17(c_wid17) SY-VLINE.
FORMAT COLOR 1 OFF.
uline.
endform.                           "write_column_headings
    FORM WRITE_OUTPUT
Write list output
form write_output.
loop at i_output.
    perform set_background_color.
  write: at /w_wid01(c_wid01) SY-VLINE,
         at  w_wid02(c_wid02) i_output-werks,
         at  w_wid03(c_wid03) SY-VLINE,
         at  w_wid04(c_wid04) i_output-mtart,
         at  w_wid05(c_wid05) SY-VLINE,
         at  w_wid06(c_wid06) i_output-matnr,
         at  w_wid07(c_wid07) SY-VLINE,
         at  w_wid08(c_wid08) i_output-maktx,
         at  w_wid09(c_wid09) SY-VLINE,
         at  w_wid10(c_wid10) i_output-maxlz,
         at  w_wid11(c_wid11) SY-VLINE,
         at  w_wid12(c_wid12) i_output-lzeih,
         at  w_wid13(c_wid13) SY-VLINE,
         at  w_wid14(c_wid14) i_output-aenam,
         at  w_wid15(c_wid15) SY-VLINE,
         at  w_wid16(c_wid16) i_output-laeda,
         at  w_wid17(c_wid17) SY-VLINE.
endloop.
endform.                           "write_output
    FORM DOWNLOAD_TO_EXCEL
Download report data to excel spreadsheet
form download_to_excel.
data: row type i value '2'.
*-- Create Excel spreadsheet
  create object GS_EXCEL 'EXCEL.APPLICATION'.
   if sy-subrc <> 0.
     message e002(sy) with sy-msgli.
   endif.
   call method of GS_EXCEL 'WORKBOOKS' = GS_BOOKS.
   call method of GS_BOOKS 'ADD' = GS_WBOOK.
*-- Add column headers
   perform fill_cell using 1 1 'Plant'.
   perform fill_cell using 1 2 'Material Type'.
   perform fill_cell using 1 3 'Material Number'.
   perform fill_cell using 1 4 'Material Description'.
   perform fill_cell using 1 5 'Max Storage'.
   perform fill_cell using 1 6 'Time Unit'.
   perform fill_cell using 1 7 'Changed By'.
   perform fill_cell using 1 8 'Last Changed On'.
loop at i_output.
   perform fill_cell using row 1 i_output-werks.
   perform fill_cell using row 2 i_output-mtart.
   perform fill_cell using row 3 i_output-matnr.
   perform fill_cell using row 4 i_output-maktx.
   perform fill_cell using row 5 i_output-maxlz.
   perform fill_cell using row 6 i_output-lzeih.
   perform fill_cell using row 7 i_output-aenam.
   perform fill_cell using row 8 i_output-laeda.
   row = row + 1.
endloop.
*-- Set name of spreadsheet
  call method of GS_EXCEL 'ACTIVESHEET' = GS_SHEET.
  set property of GS_SHEET 'NAME' = 'Max Storage Period'.
*-- Set orientaion to landscape.
  call method of GS_SHEET 'PAGESETUP' = GS_PAGE.
  set property of GS_PAGE 'ORIENTATION' = 2.
  free object GS_PAGE.
*-- Make column headers bold and centered
  call method of GS_SHEET 'RANGE' = GS_RANGE exporting #1 = 'A1:Z1'.
  set property of GS_RANGE 'HORIZONTALALIGNMENT' = 3.
  call method of GS_RANGE 'FONT' = GS_FONT.
  set property of GS_FONT 'BOLD' = 1.
  free object GS_RANGE.
  free object GS_FONT.
*-- Set column widths to autofit
  call method of GS_SHEET 'RANGE' = GS_RANGE exporting #1 = 'A1:Z1'.
  set property of GS_RANGE 'COLUMNS' = GS_COLS.
  call method of GS_COLS 'AUTOFIT'.
*-- Display spreadsheet
  set property of GS_EXCEL 'VISIBLE' = 1.
*-- Free OLE objects
  free object GS_EXCEL.
  free object GS_BOOKS.
  free object GS_WBOOK.
  free object GS_SHEET.
  free object GS_RANGE.
  free object GS_COLS.
  free object GS_CELL.
endform.                           "download_to_excel
    FORM FILL_CELL
Add report fields to Excel sheet
form fill_cell using row col value.
call method of GS_EXCEL 'CELLS' = GS_CELL exporting #1 = row
                                               #2 = col.
set property of GS_CELL 'VALUE' = VALUE.
free object GS_CELL.
endform.
----</b>

Similar Messages

  • OLE Automation with Excel

    Hi All,
    Does anyone know of any reference/help/material on how to use OLE automation to download and format data from ABAP to Excel.
    I need to know what the available methods and properties are so I could format the data the way I want.
    Any help will be greatly appreciated.
    Regards.

    Hi Aurang
    You can call almost all methods using OLE. What is required is to know how to interpret a script to ABAP OLE call. This is explained in the tutorial<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c1d54348-0601-0010-3e98-bd2a2dcd9e6c">"An Easy Reference For OLE Automation"</a>
    Regards
    *--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

  • Call OpenOffice through OLE Automation

    Hello everybody,
    I am trying to open an OpenOffice Calc window (similar to Excel)
    from ABAP through OLE automation. My problem with this: it
    is necessary to call an automation method of OpenOffice that
    has a SAFEARRAY (OLE data type) as one of its parameters.
    How do I create a data type that maps to SAFEARRAY in ABAP?
    I have found no example for this.
    My program looks like this, the missing line is the one that
    starts with #4:
    REPORT ZCALC2 NO STANDARD PAGE HEADING.
    INCLUDE OLE2INCL.
    DATA: SERVICE_MANAGER TYPE OLE2_OBJECT,
    DESKTOP TYPE OLE2_OBJECT,
    DOCUMENT TYPE OLE2_OBJECT.
    CREATE OBJECT SERVICE_MANAGER 'com.sun.star.ServiceManager'.
    CALL METHOD OF SERVICE_MANAGER 'createInstance' = DESKTOP
    EXPORTING #1 = 'com.sun.star.frame.Desktop'.
    CALL METHOD OF DESKTOP 'loadComponentFromURL' = DOCUMENT
    EXPORTING #1 = 'private:factory/scalc'
              #2 = '_blank'
              #3 = 0
              #4 = ''.
    FREE OBJECT SERVICE_MANAGER.
    When I run the program, the CALL METHOD returns SY-SUBRC code 2 and I see the following in the trace file:
    <1950=(Error): CALL METHOD "loadComponentFromURL" OF [#13/0x00229C9C/402]
                        #0: STRING "private:factory/scalc"
                        #1: STRING "_blank"
                        #2: LONG "0"
                        #3: STRING ""
    IDispatch::Invoke raised exceptionTypkonflikt.
    <1950=(Error):                                                 Exception fire by :[automation bridge]
    <1950=(Error):                                                 Exception info:conversion not possible!
    <1950=(Error):                                                 Exception code:1001
    <1950=(Error):                  Error occured at Verb  : loadComponentFromURL
    <1950=(Error):                                   Object: 13
    <1950=(Error): SAPAWRFC leaving RfcFlushOle with RfcRaise(CALL_METHOD_FAILED)
    See the <a href="http://api.openoffice.org/docs/common/ref/com/sun/star/frame/XComponentLoader.html">loadComponentFromURL</a> documentation for information on the parameters. Unfortunately it is in UNO IDL, which is specific to OpenOffice. However, a <a href="http://udk.openoffice.org/common/man/spec/ole_bridge.html">mapping</a> to OLE types is available.
    There are many examples how to do this in other programming languages, for example <a href="http://www.oooforum.org/forum/viewtopic.phtml?t=9815">here</a>, but I could not find it in ABAP.
    Thanks for your help,
    Frederic.

    Here is another interesting thing: it's possible to let OpenOffice open a multi selection file dialog from ABAP. It works like this:
    CALL METHOD OF SERVICE_MANAGER 'createInstance' = DIALOG
    EXPORTING #1 = 'com.sun.star.ui.dialogs.FilePicker'.
    CALL METHOD OF DIALOG 'setTitle'
    EXPORTING #1 = 'Hello from ABAP'.
    CALL METHOD OF DIALOG 'setDisplayDirectory'
    EXPORTING #1 = 'file:///C:'.
    CALL METHOD OF DIALOG 'setMultiSelectionMode'
    EXPORTING #1 = 1.
    CALL METHOD OF DIALOG 'Execute'.
    CALL METHOD OF DIALOG 'getFiles' = FILE_ARRAY.
    According to the documentation, last line returns an empty array if no file has been selected. My hope was that I could use this as the 4th parameter of loadComponentFromURL, but I still get "conversion not possible".
    I also wonder what should be the type of FILE_ARRAY - I expected OLE2_OBJECT, but if I try that, I can see in the debugger that the object is not properly initialized (HEADER and TYPE are not 'OBJH' and 'OLE2').

  • PICTURE MTHOD in OLE AUTOMATION

    Hi,
       Can anyone send me information for the "picture" method using OLE AUTOMATION for Excel Objects.
    Thanks and Regards
    AK

    hi
    good
    go through the following links i hope this will help you to solve your problem.
    Re: OLE Automation with Excel
    http://www.sap-img.com/abap/download-to-excel-with-format-border-color-cell-etc.htm
    http://sap.ittoolbox.com/code/archives.asp?d=3027&a=s&i=10
    thanks
    mrutyun

  • OLE automation

    Auteur : Corinne Ribeyre-F085785 &agrave; _CARPO04
    I need help with OLE Automation implementation (Excel,
    CrystalReport,Word ...)
    I generate Excel project with OleGen but no documentation exist for
    this project. So I made severals tests (with Excel).
    I can do (see examples):
    - open a file
    - open Excel Application
    - open WorkBook, WoorkSheet
    - Write and Read a Cell (but I am not sure it's the more efficient
    method to do this)
    - run a macro with parameters
    But, I CAN'T do:
    - run a command with parameters like PivotTableWizard (tableau croise
    dynamique)
    Does a Documentation exist about Forte project generated by Olegen
    Tool (Excel..) ?
    Does a Documentation exist about Forte/Crystal Report ?
    Thank You for all answers and examples,
    Corinne
    Examples
    -- Open Excel
    theApplication : Excel . Application = New;
    theApplication . CreateUsingProgID(NX('excel.application'));
    --- Excel Visible /not visible
    theApplication . Visible = VariantBoolean(Value = False);
    -- Get all WorkBooks of Excel Application
    theWorkBooks : Excel . WorkBooks = New;
    theWorkBooks . SetDispatchObject(theApplication . Workbooks());
    -- Open File.xls (added with previous Application)
    theWorkBooks . Open (VariantString(Value = 'C:\\temp\\File.xls'));
    -- Link file with a WorkBook
    aWorkBook : Excel . WorkBook = New;
    aWorkBook . SetDispatchObject(theApplication .
    Workbooks(VariantString(value='File.xls')));
    -- Link a Folder (Sheet1) from File with WorkSheet
    aWorksheet : Excel . Worksheet = New;
    aWorksheet . SetDispatchObject(aWorkBook .
    Worksheets(VariantString(value='Sheet1')));
    aRange : Excel . Range = New;
    -- Fill Cell (1,1) with 'Article'
    TitreArt : VariantString = VariantString(Value = 'Article');
    aRange . SetDispatchObject(aWorksheet . Cells(VariantInteger(Value =
    1), VariantInteger(Value = 1)));
    aRange . Value = titreArt;
    -- Fill Cell (1,2) with 'Date'
    TitreDate : VariantString = VariantString(Value = 'Date');
    aRange . SetDispatchObject(aWorksheet . Cells(VariantInteger(Value =
    1), VariantInteger(Value = 2)));
    aRange . Value = TitreDate;
    -- Run a Macro
    theApplication . Run(VariantString(Value = NX('MacroName')),
    VariantInteger(Value = 65),
    VariantInteger(Value = 7));
    -- Page Setup
    -- Link a Folder (Sheet2) from File with WorkSheet
    aWorksheet . SetDispatchObject(aWorkBook .
    Worksheets(VariantString(value='Sheet2')));
    aPageSetup : Excel . PageSetUp = New;
    aPageSetup . SetDispatchObject(aWorksheet.PageSetup);
    aPageSetup . PrintTitleRows = VariantString (Value = '');
    aPageSetup . PrintTitleColumns = VariantString (Value = '');
    aPageSetup . LeftHeader = VariantString (Value = 'MICKEY');
    aPageSetup . CenterHeader = VariantString (Value = 'MOUSE');
    aPageSetup . RightHeader = VariantString (Value = '&J &H'); --
    Attention J H en Excel Fran&ccedil;ais; D T en Anglais
    aPageSetup . LeftFooter = VariantString (Value = '');
    aPageSetup . CenterFooter = VariantString (Value = 'DISNEYLAND
    PARIS');
    aPageSetup . RightFooter = VariantString (Value = '&P / &T');
    aPageSetup . LeftMargin = VariantInteger(Value = 1);
    aPageSetup . RightMargin = VariantInteger(Value = 1);
    aPageSetup . TopMargin = VariantInteger(Value = 1);
    aPageSetup . BottomMargin = VariantInteger(Value = 1);
    aPageSetup . HeaderMargin = VariantDouble(Value = 0.5);
    aPageSetup . FooterMargin = VariantDouble(Value = 0.5);
    aPageSetup . PrintHeadings = VariantBoolean(Value = False);
    aPageSetup . PrintGridlines = VariantBoolean(Value = False);
    aPageSetup . PrintNotes = VariantBoolean(Value = False);
    aPageSetup . CenterHorizontally = VariantBoolean(Value = True);
    aPageSetup . CenterVertically = VariantBoolean(Value = True);
    aPageSetup . Orientation = VariantInteger(Value = 2); --
    (1:xlPortrait, 2:xlLandscape)
    aPageSetup . Draft = VariantBoolean(Value = False);
    aPageSetup . PaperSize = VariantInteger(Value = 9);
    -- (8: xlPaperA3, 9: xlPaperA4)
    aPageSetup . FirstPageNumber = VariantInteger(Value = -4105);
    -- xlAutomatic
    aPageSetup . Order = VariantInteger(Value = 1);
    -- xlDownThenOver
    aPageSetup . BlackAndWhite = VariantBoolean(Value = True);
    aPageSetup . Zoom = VariantBoolean(Value = False);
    aPageSetup . FitToPagesWide = VariantInteger(Value = 1);
    aPageSetup . FitToPagesTall = VariantInteger(Value = 1);
    -- Save File
    aFilename : VariantString = VariantString(Value =
    NX('C:/Temp/Essai.xls'));
    aWorkBook . SaveAS(FileName = aFilename);
    -- Print File
    PrintOptions : PrintOptionsDesc;
    PrintOptions = Self . Window . WindowSystem . DefaultPrintOptions .
    Clone (Deep = True);
    If (self.Window.PrintDialog (PrintOptions= PrintOptions,
    ShowSetupDialog = TRUE,
    ShowJobDialog = FALSE) = BV_OK) Then
    aWorksheet . PrintOut();
    End If;
    -- Unlink
    aWorkBook . RunAutoMacros(VariantInteger(Value = 2)); --xlAutoFermer 
    -- Cf doc VBA
    aWorkBook . Close(variantboolean (Value = False));
    TheApplication . Quit();
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    Hi all, forget this silly question...
    I studied a little bit and learned how to handle OLEs properly...
    Many thanks

  • Is it possible to create Excel Sheet using OLE automation in App server

    Hi,
       Is it possible to create Excel Sheet using OLE automation in Application server(Open Dataset)
    Thanks in advance...

    Unless your application server is on Windows OS, or it is connected to a Windows server by RFC. What is the requirement exactly, I don't understand?

  • OLE Automation: EXCEL not starting

    I am using OLE Automation to download table data to a spreasheet.  I got everything working, and EXCEL starts and sheets get created and populated with the data.  Everything appears fine.  When I had my co-workers test it, EXCEL doesn't start up for them, and nothing happens.  What could this be?

    I've tried having my co-workers open EXCEL first, and it doesn't matter.  They still get nothing.  Mine, however, starts when I don't have EXCEL open.  If I do have it open, it brings up a new window of EXCEL.

  • OLE Automation is not working in Portal

    Hi Experts,
    We have one report where OLE automation technique is used to upload the data from multiple worksheets (single excel).
    But when we try to execute it from Portal using IView then it doesn't run and give problem in CREATE OBJECT excel "EXCEL.APPLICATION" statement. But when we run it from SAP GUI, it run successfully.
    Please suggest if you have any idea.
    Also let me know if some more information required because i am new to this kind of issue. 
    regards
    Subir

    Hi,
    Are you using SAP GUI for HTML??? There are several issues and limitations with OLE using HTML.
    Look this OSS: 314568
    Hope this helps,
    Iván.

  • Performance in OLE Automation

    Hello.
    We're using OLE automation to generate formatted Excel in a client. They wanted to have data in Excel with formulas, locked cells, colors, logos, etc.
    The problem is that we're having performance issues when we work with more than 1.000 records. We're having timeouts and low memory.
    I'm wondering if someone who worked with that could tell me if there's a limit of records to work with this approach or if there's a way to improve performance for OLE automation??.
    If we're working with too many records, is there another way to generate formatted excel from R3??.

    Hi Joaquin,
    For inserting many lines you should better use the OO technique instead of OLE. Check the help on Desktop Office Integration (e.g. for 4.6C):"
    http://help.sap.com/saphelp_46c/helpdata/en/e9/0bee9f408e11d1893b0000e8323c4f/frameset.htm
    Regards,
    John.

  • OLE automation access

    Hello,
    I'm trying to understand what the OLE automation object is, and how I can access and use the data inside.
    My problem is that the OLE "clipholder" is carriyng some data of a couple of cells in an excel-spreadsheet-type document that is updated about five times pr second. And I don't know how to retrieve this data real-time with Java.
    Any suggestions?
    - Rendse

    You make an interface to the DLL you want to use that supports the features you need--this is done via Java Native Interface and C/C++. There is a separate JNI forum.

  • OLE Automation , date formatting

    Hi everybody,
    i have a problem with OLE automation for "date" formatting.
    The cell value is correct ( DD/MM/YYYY) , but in some cases the cell option is "Date" ( this is the correct option ) and in other cases the cell option is "General". This last option is wrong because the value is left-justified, meanwhile the "Date" option is right-justified.
    I wish to have the "Date" cell option always. (right-justified)
    Is it possible to set this option with statement "SET PROPERTY OF..." ?
    Thanks in advance.
    Best regards.
    Dario.

    Hi,
    you can use this:
      SET PROPERTY OF H_CELL 'NumberFormat' =
                             'dd\/mm\/yyyy'.
      SET PROPERTY OF H_CELL 'Value'        = '01/01/2012'.
    Regards, Dieter

  • [b]Tutorial:[/b] Simplify Developing OLE Automation Code Using VBA

    INTRODUCTION
    Automating Office applications from Oracle Forms can be a tedious, frustrating, and time-consuming process. Because the OLE2 and CLIENT_OLE2 built-ins do not validate the automation commands that they relay, code that compiles without errors often dies at runtime with a not-so-helpful error code. This tutorial will demonstrate how to simplify the development of automation code using a tool that ships with all Microsoft Office editions -- the Visual Basic for Applications (VBA) IDE.
    The VBA IDE, a core Office component, is a full-fledged development environment featuring code completion, basic syntax highlighting, context-driven help and a runtime debugger. Its Object Browser provides a convenient means of browsing the Word object model, as well as searching by keyword.
    For those who may not interested in following this tutorial in detail, I would like to stress the usefulness of the Object Browser as a tool for inspecting the functions supported by OLE server applications and, perhaps more importantly, valid values for function arguments. Whether/not anyone buys the assertion that starting with VBA prototypes is far more productive than pounding out OLE2 code from the very start, they will find the Object Browser invaluable as a reference -- I rely on it exclusively for this sort of documentation.
    A BRIEF INTRODUCTION TO THE VBA IDE & THE OBJECT BROWSER UTILITY
    Try this:
    1. Open Word
    2. Launch the VBA IDE by pressing <Alt><F11>
    3. Open the Object Browser by pressing <F2>
    The Object Browser allows you to visually navigate Word's class hierarchy. Its user interface is a bit crowded, so controls are unlabeled. Hovering the mouse cursor above a control will display a tooltip explaining that control's purpose. The browser's scope can be narrowed by using the Project/Library combo. Typing a keyword or substring in the Search Text combo and clicking on the Search button will cause all classes/members whose name contains the specified search text to be listed in the Search Results pane. Selecting an item from this list will update the two panes below it, showing the selected class, and its members. Beneath the Classes and Members panes is an untitled pane, gray in color, which displays details for the selected class/member, including hyperlinks to relevant information such as arguments, their types and allowable values. If Visual Basic Help is installed, pressing <F1> will display help on a selected class/member. (This feature can be installed from your Office install CD, if necessary.)
    NOTE: While it is possible to cut-and-paste the code examples that follow, I highly recommend that they be typed in by hand. Doing so will provide a better understanding of how the IDE's code completion behaves. Use code completion most efficiently by not using the mouse or <Enter> key when selecting from completion lists. Instead, just type enough letters to select the desired list element, then continue along as if you had typed the entire element, typing the next operator in your statement. It really is slick!
    HELLO WORLD - VBA-STYLE
    1. Open Word
    2. Launch the VBA IDE by pressing <Alt><F11>
    3. Select Module from the Insert menu.
    4. In the blank area that appears, enter the following code:
      Public Sub HelloWorld()
          Documents.Add
          Selection.TypeText ("Hello, world!")
      End Sub5. Press <F5> to run the code.
    If you switch back to Word by pressing <Alt><F11>, there should appear a newly-created document containing the text Hello, world!.
    A MORE AMBITIOUS EXAMPLE
    In this example, we will launch Word, type some text, and alter its formatting. For the purposes of this tutorial, consider it the process we wish to automate from within Forms.
    1. If Word is running, close it.
    2. Open any Office application except Word, such as Excel, Outlook or PowerPoint
    3. Launch the VBA IDE by pressing <Alt><F11>.
    4. Select References from the Tools menu -- a dialog should pop up.
    5. From within this dialog, locate and select Microsoft Word <version> Object Library, then click OK.
    6. Select Module from the Insert menu.
    7. In the blank area that appears, enter the following code:
    Public Sub LaunchWord()
        Dim app As Word.Application
        Set app = CreateObject("Word.Application")
        app.Visible = True                          '!!! IMPORTANT !!!
        app.Documents.Add
        With app.Selection
            .TypeText "This is paragraph 1."
            .TypeParagraph
            .TypeText "This is paragraph 2."
            .TypeParagraph
            .TypeText "This is paragraph 3."
        End With
        With ActiveDocument
            .Paragraphs(1).Range.Words(3).Bold = True
            .Paragraphs(2).Range.Words(3).Italic = True
            .Paragraphs(3).Range.Words(3).Underline = True
        End With
    End Sub8. Press <F5> to run the code.
    A new Word session should have been launched. Switch to it, to view the results of our handiwork!
    TAILORING VBA CODE INTENDED FOR OLE2 CONVERSION
    Now, things get a bit uglier. The code listed above gives a good idea of how concise VBA code can be, but With blocks and chained object references do not translate readily into OLE2 code. Here's the same process, rewritten in a more OLE2-friendly style. Note the numerous intermediate object references that have been declared.
    Public Sub LaunchWord()
        Dim app As Word.Application
        Dim doc As Word.Document
        Dim docs As Word.Documents
        Dim pars As Word.Paragraphs
        Dim par As Word.Paragraph
        Dim wrds As Word.Words
        Dim sel As Word.Selection
        Dim rng As Word.Range
        Set app = CreateObject("Word.Application")
        app.Visible = True                          '!!! IMPORTANT !!!
        Set doc = app.Documents.Add
        Set sel = app.Selection
        sel.TypeText "This is paragraph 1."
        sel.TypeParagraph
        sel.TypeText "This is paragraph 2."
        sel.TypeParagraph
        sel.TypeText "This is paragraph 3."
        Set pars = doc.Paragraphs
        'select third word of first paragraph and make it bold
        Set par = pars.Item(1)
        Set rng = par.Range
        Set wrds = rng.Words
        Set rng = wrds.Item(3)
        rng.Bold = True
        'select third word of second paragraph and italicize it
        Set par = pars.Item(2)
        Set rng = par.Range
        Set wrds = rng.Words
        Set rng = wrds.Item(3)
        rng.Italic = True
        'select third word of second paragraph and underline it
        Set par = pars.Item(3)
        Set rng = par.Range
        Set wrds = rng.Words
        Set rng = wrds.Item(3)
        rng.Underline = True
    End Sub
    TRANSFORMATION: CONVERTING VBA CODE INTO PL/SQL
    Here is the PL/SQL counterpart to our previous VBA routine. Compare printouts of the two and note their similarities. Notice the need for argument lists -- this causes the code to fluff up quite a bit, and really interferes with readability.
    PROCEDURE LAUNCH_WORD IS
      v_app OLE2.OBJ_TYPE;     -- Application
      v_doc OLE2.OBJ_TYPE;     -- Document
      v_docs OLE2.OBJ_TYPE;    -- Documents collection
      v_pars OLE2.OBJ_TYPE;    -- Paragraphs collection
      v_par OLE2.OBJ_TYPE;     -- Paragraph
      v_wrds OLE2.OBJ_TYPE;    -- Words collection
      v_sel OLE2.OBJ_TYPE;     -- Selection
      v_rng OLE2.OBJ_TYPE;     -- Range
      v_args OLE2.LIST_TYPE;   -- OLE2 argument list
    BEGIN
      /* launch Word and MAKE IT VISIBLE!!! */ 
        v_app := OLE2.CREATE_OBJ('Word.Application');
        OLE2.SET_PROPERTY(v_app, 'Visible', TRUE);
      /* initialize key object references */ 
        v_docs := OLE2.GET_OBJ_PROPERTY(v_app, 'Documents');
        v_doc := OLE2.INVOKE_OBJ(v_docs, 'Add');
        v_sel := OLE2.GET_OBJ_PROPERTY(v_app, 'Selection');
      /* type first paragraph */
        v_args := OLE2.CREATE_ARGLIST;
        OLE2.ADD_ARG(v_args, 'This is paragraph 1.');
        OLE2.INVOKE(v_sel, 'TypeText', v_args);
        OLE2.DESTROY_ARGLIST(v_args);
        OLE2.INVOKE(v_sel, 'TypeParagraph');
      /* type second paragraph */
        v_args := OLE2.CREATE_ARGLIST;
        OLE2.ADD_ARG(v_args, 'This is paragraph 2.');
        OLE2.INVOKE(v_sel, 'TypeText', v_args);
        OLE2.DESTROY_ARGLIST(v_args);
        OLE2.INVOKE(v_sel, 'TypeParagraph');
      /* type third paragraph */
        v_args := OLE2.CREATE_ARGLIST;
        OLE2.ADD_ARG(v_args, 'This is paragraph 3.');
        OLE2.INVOKE(v_sel, 'TypeText', v_args);
        OLE2.DESTROY_ARGLIST(v_args);
      /* set reference to Paragraphs collection */
        v_pars := OLE2.GET_OBJ_PROPERTY(v_doc, 'Paragraphs');
      /* select third word of first paragraph and make it bold */
        v_args := OLE2.CREATE_ARGLIST;
        OLE2.ADD_ARG(v_args, 1);
        v_par := OLE2.INVOKE_OBJ(v_pars, 'Item', v_args);
        OLE2.DESTROY_ARGLIST(v_args);
        v_rng := OLE2.GET_OBJ_PROPERTY(v_par, 'Range');
        v_wrds := OLE2.GET_OBJ_PROPERTY(v_rng, 'Words');
        v_args := OLE2.CREATE_ARGLIST;
        OLE2.ADD_ARG(v_args, 3);
        v_rng := OLE2.INVOKE_OBJ(v_wrds, 'Item', v_args);
        OLE2.SET_PROPERTY(v_rng, 'Bold', TRUE);
      /* select third word of second paragraph and italicize it */
        v_args := OLE2.CREATE_ARGLIST;
        OLE2.ADD_ARG(v_args, 2);
        v_par := OLE2.INVOKE_OBJ(v_pars, 'Item', v_args);
        OLE2.DESTROY_ARGLIST(v_args);
        v_rng := OLE2.GET_OBJ_PROPERTY(v_par, 'Range');
        v_wrds := OLE2.GET_OBJ_PROPERTY(v_rng, 'Words');
        v_args := OLE2.CREATE_ARGLIST;
        OLE2.ADD_ARG(v_args, 3);
        v_rng := OLE2.INVOKE_OBJ(v_wrds, 'Item', v_args);
        OLE2.SET_PROPERTY(v_rng, 'Italic', TRUE);
      /* select third word of second paragraph and underline it */
        v_args := OLE2.CREATE_ARGLIST;
        OLE2.ADD_ARG(v_args, 3);
        v_par := OLE2.INVOKE_OBJ(v_pars, 'Item', v_args);
        OLE2.DESTROY_ARGLIST(v_args);
        v_rng := OLE2.GET_OBJ_PROPERTY(v_par, 'Range');
        v_wrds := OLE2.GET_OBJ_PROPERTY(v_rng, 'Words');
        v_args := OLE2.CREATE_ARGLIST;
        OLE2.ADD_ARG(v_args, 3);
        v_rng := OLE2.INVOKE_OBJ(v_wrds, 'Item', v_args);
        OLE2.SET_PROPERTY(v_rng, 'Underline', TRUE);
    END;
    REFACTORING FOR REUSABILITY AND READABILITY
    While the previous procedure runs without errors, it suffers from poor readability which, in turn, makes it difficult to maintain. Here, we address those issues by moving repetetive low-level operations into separate procedures.
      PROCEDURE LAUNCH_WORD IS
        v_app OLE2.OBJ_TYPE;    -- Application
        v_doc OLE2.OBJ_TYPE;    -- Document
        v_docs OLE2.OBJ_TYPE;   -- Documents collection
        v_sel OLE2.OBJ_TYPE;    -- Selection
        v_args OLE2.LIST_TYPE;  -- OLE2 argument list
      BEGIN
        /* launch Word and MAKE IT VISIBLE!!! */ 
          v_app := OLE2.CREATE_OBJ('Word.Application');
          OLE2.SET_PROPERTY(v_app, 'Visible', TRUE);
        /* create a new Word document */ 
          v_docs := OLE2.GET_OBJ_PROPERTY(v_app, 'Documents');
          v_doc := OLE2.INVOKE_OBJ(v_docs, 'Add');
          v_sel := OLE2.GET_OBJ_PROPERTY(v_app, 'Selection');
        /* add a few paragraphs */
          PRINT_PARAGRAPH(v_sel, 'This is paragraph 1.');
          PRINT_PARAGRAPH(v_sel, 'This is paragraph 2.');
          PRINT_PARAGRAPH(v_sel, 'This is paragraph 3.');
        /* apply formatting */
          APPLY_FORMATTING(v_doc, 1, 3, 'Bold', TRUE);
          APPLY_FORMATTING(v_doc, 2, 3, 'Italic', TRUE);
          APPLY_FORMATTING(v_doc, 3, 3, 'Underline', TRUE);
      END;
      PROCEDURE APPLY_FORMATTING(
        v_doc OLE2.OBJ_TYPE,
        v_paragraph_num NUMBER,
        v_word_num NUMBER,
        v_attribute VARCHAR2,
        v_value BOOLEAN) IS
        v_pars OLE2.OBJ_TYPE;   -- Paragraphs collection
        v_par OLE2.OBJ_TYPE;    -- Paragraph
        v_wrds OLE2.OBJ_TYPE;   -- Words collection
        v_rng OLE2.OBJ_TYPE;    -- Range
        v_args OLE2.LIST_TYPE;  -- OLE2 argument list
      BEGIN
        /* set reference to Paragraphs collection */
          v_pars := OLE2.GET_OBJ_PROPERTY(v_doc, 'Paragraphs');
        /* get specified paragraph */   
          v_args := OLE2.CREATE_ARGLIST;
          OLE2.ADD_ARG(v_args, v_paragraph_num);
          v_par := OLE2.INVOKE_OBJ(v_pars, 'Item', v_args);
          OLE2.DESTROY_ARGLIST(v_args);
        /* get words for specified paragraph */
          v_rng := OLE2.GET_OBJ_PROPERTY(v_par, 'Range');
          v_wrds := OLE2.GET_OBJ_PROPERTY(v_rng, 'Words');
        /* apply formatting to word found at specified index */
          v_args := OLE2.CREATE_ARGLIST;
          OLE2.ADD_ARG(v_args, v_word_num);
          v_rng := OLE2.INVOKE_OBJ(v_wrds, 'Item', v_args);
          OLE2.SET_PROPERTY(v_rng, v_attribute, v_value);
      END;
      PROCEDURE PRINT_PARAGRAPH(v_sel OLE2.OBJ_TYPE, v_text VARCHAR2) IS
        v_args OLE2.LIST_TYPE;
      BEGIN
        v_args := OLE2.CREATE_ARGLIST;
        OLE2.ADD_ARG(v_args, v_text);
        OLE2.INVOKE(v_sel, 'TypeText', v_args);
        OLE2.DESTROY_ARGLIST(v_args);
        OLE2.INVOKE(v_sel, 'TypeParagraph');
      END;
    CONCLUSION
    It is my hope that this tutorial, despite it's introductory nature, has demonstrated the value of the VBA IDE, the ease with which automation processes can be prototyped using VBA, the noticeable similarity between VBA automation routines and their Forms PL/SQL counterparts, and the advantages of testing automation processes within the VBA IDE. Please feel free to follow up with any specific questions or concerns you may have.
    Thanks,
    Eric Adamson
    Lansing, Michigan
    FINAL NOTE: These examples use the OLE2 built-in, and will operate correctly when called from forms running in the Form Builder OC4J. Deploying them to an Oracle Application Server will launch Word on the server itself (if available), which is usually not the developer's intent! Automating Word client-side via web forms requires adding WebUtil support. Adapting the code for WebUtil is trivial -- just replace all instances of OLE2 with CLIENT_OLE2. Adapting forms for WebUtil and configuring OLE support into your Oracle Application Server, however, are beyond the scope of this tutorial.
    REVISION HISTORY
    This promises to be something of a 'living document'. I've snuck changes through without comment in the past, but in the future, I'll try to document significant changes here.
    2006-08-21
      * Prefaced boring subject line with text: 'Tutorial:' to clarify purpose
      * Added emphasis on value of Object Browser as a reference

    Thanks James, for your kind words. I do hope this information will help folks out. I honestly believe that tinkering around in the VBA IDE will prove highly gratifying for automation developers. It can be assured that learning to make Word jump through hoops is much more straight-forward in this environment. I'm not one for mottos, but if I were pressed for a cheesy motto, I would say: First, make it work. Then, make it work in Oracle!
    Once the idea has sunk in, that Visual Basic routines for automating Word are exact analogs to their OLE2 counterparts, we can remove keywords like Oracle and PL/SQL from our Google searches on Word automation which, at least in this context, are the proverbial kiss of death. Suddenly we find ourselves liberated by the possibility of steal-, ahem... borrowing ideas from the Visual Basic* community!
    As for links, my link of choice is invariably http://groups.google.com -- if you don't already use it at least ten times a day, you must try it. This is the venerable USENET archive, including the holdings of now-extinct DejaNews. Another possible site of interest is http://word.mvps.org/FAQs/MacrosVBA, which may serve as a good starting point for those who wish to learn how to do fancy tricks with Word using VBA.
    If these links don't prove immediately helpful, please feel free to give specifics on the sort of operations you are interested in automating, and I'll see if I can post an example that addresses it.
    Regards,
    Eric Adamson
    Lansing, Michigan
    PS: I do hope, as people read my posts, with every other acronym being VBA, that they are not mistakenly hearing a call to learn Visual Basic. I say this, not because I believe learning VB would be a Bad Thing, but because I assume that few of us feel we have the time to learn a new programming language. Despite having come to the Oracle camp already knowing VB/VBA, and having acquired a fair bit of experience with automating Office applications as an Access developer, I remain confident that what I am suggesting people attempt does not rise to the level of learning a language. What I am suggesting is that they learn enough of the language to get by.
    *VB vs. VBA
    Just a quick word on this, as readers may wonder why I seem to use these terms interchangeably. Visual Basic (VB) can refer to either a development platform or a programming language. Visual Basic for Applications (VBA) is a language -- more precisely, it is a subset of the Visual Basic language. One purchases VB, usually quite intentionally. VBA is included with Microsoft Office, as is VBA's development environment, the VBA IDE. The key distinction between VB and VBA is that VBA cannot be used to create self-contained executables. Rather, VBA relies on VBA-enabled applications, such as Microsoft Office applications, to serve as a container for VBA code, and to provide a runtime environment for that code. For the purposes of discussing OLE Automation, VB and VBA are quite interchangeable.

  • OLE Automation for Word. EditGoto with Word 97

    I found a solution. Instead EditGoto, use WW7_EditGoto.
    Example:
    .- A Word Template whith two bookmarks
    (Texto1, Tabla1). A normal bookmark
    (Texto1) and a bookmark into a Word
    Table (Tabla1).
    In the Word Table, is posible change
    cell o create a new row with the same
    command (NextCell).
    The word table has two columns an two
    rows.
    The first row is the Header.
    The second row the first column contain
    a bookmark (Tabla1).
    .- A Form whit two blocks:
    First block with two items:
    nombre_doc
    texto1
    Secod Block (multirecord) whit two items
    col1
    col2
    with a When-Button-Pressed:
    DECLARE
    application OLE2.OBJ_TYPE;
    args OLE2.LIST_TYPE;
    BEGIN
    -- Start WordBasic and make Word visible
    application:=OLE2.CREATE_OBJ('Word.Basic');
    OLE2.INVOKE(application, 'AppShow');
    -- Open a Word document
    args := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(args,'Plantilla.dot');
    OLE2.INVOKE(application, 'FileOpen', args);
    OLE2.DESTROY_ARGLIST(args);
    -- Put Text in the first bookmark
    args := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(args,'Texto1');
    OLE2.INVOKE(application, 'WW7_EditGoto', args);
    OLE2.DESTROY_ARGLIST(args);
    args := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(args,:Texto1);
    OLE2.INVOKE(application, 'Insert', args);
    OLE2.DESTROY_ARGLIST(args);
    -- Send data from Multirecord Block to Word Table
    GO_BLOCK('MULTI');
    FIRST_RECORD;
    IF :SYSTEM.RECORD_STATUS != 'NEW' THEN
    args := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(args,'Tabla1');
    OLE2.INVOKE(application, 'WW7_EditGoto', args);
    OLE2.DESTROY_ARGLIST(args);
    LOOP
    IF :col1 IS NOT NULL THEN
    args := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(args,:col1);
    OLE2.INVOKE(application, 'Insert', args);
    OLE2.DESTROY_ARGLIST(args);
    END IF;
    OLE2.INVOKE(application, 'NextCell');
    IF :col2 IS NOT NULL THEN
    args := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(args,:col2);
    OLE2.INVOKE(application, 'Insert', args);
    OLE2.DESTROY_ARGLIST(args);
    END IF;
    EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE';
    NEXT_RECORD;
    OLE2.INVOKE(application, 'NextCell');
    END LOOP;
    -- Save a Word document
    args := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(args,:nombre_doc);
    OLE2.INVOKE(application, 'FileSaveas', args);
    OLE2.DESTROY_ARGLIST(args);
    --Release the OLE object
    OLE2.RELEASE_OBJ(application);
    END;
    Sorry by the sintax, but i don't speak English.
    I hope it solves this problem.

    Hello,
    I am also trying to use the OLE2 package for OLE Automation. But
    difference being that I am not using Word but am using an
    invisible control for Mail services, using the objects
    MAPISession, MAPImessages. If anyone out there had already done
    this do please give me a code snippet.
    Thanx in advance
    Anup Mistry,
    Programmer/Analyst,
    IIS,Inc
    Vasile (guest) wrote:
    : Hi Daniel,
    : I used OLE with forms 5 ,but now it work without problems in
    : forms 6, too.
    : A procedure that save doc. look like that:
    : procedure filesaveas (fname in varchar2) is
    : arglist ole2.list_type;
    : begin
    : arglist := ole2.create_arglist;
    : ole2.add_arg (arglist, fname);
    : ole2.invoke (obj_hnd, 'filesaveas', arglist);
    : ole2.destroy_arglist (arglist);
    : end;
    : I hope this help you.
    : Vasile
    : Daniel Fox (guest) wrote:
    : : I am using Forms 6.0
    : : Can anyone help with OLE automation using OLE2.
    : : I can open Word, document stored in long raw, even insert
    data
    : : from other form field into the Word Document (only at the
    : : beginning of the Document, though).
    : : All the File commands, such as FileSaveAs, EditGoTo, etc..
    : don't
    : : work. They are simply ignored - no error messages, nothing.
    : : Does anyone use Word Automation through Forms 6.0?
    : : Please, HELP....
    : : Thanks in advance,
    : : Desperate Daniel.
    null

  • OLE objects and OO methods - Error using OLE automation

    Hi,
    I'm developing an class to read/write excel sheets and i'm getting an error on the OLE method that is:
    on this instruction
    call method of l_obj_excel 'WORKBOOKS' = l_workb_col.
    i got a dump that give me the following error UC_OBJECTS_NOT_CONVERTIBLE
    The strange is that i've got the same code running on reports and it works fine only when passing it to a oo method i get that dump.
    Thzs in advanced to all
    Best regards
    Jaime

    hi check this..
    Report ZMULTICOLOR_TEST no standard page heading.
    this report demonstrates how to send some ABAP data to an
    EXCEL sheet using OLE automation.
    include ole2incl.
    handles for OLE objects
    data: h_excel type ole2_object,        " Excel object
          h_mapl type ole2_object,         " list of workbooks
          h_map type ole2_object,          " workbook
          h_zl type ole2_object,           " cell
          h_f type ole2_object,            " font
          h_c type ole2_object.            " color
    DATA: FILENAME LIKE RLGRAP-FILENAME.
    tables: spfli.
    data  h type i.
    table of flights
    data: it_spfli like spfli occurs 10 with header line.
    *&   Event START-OF-SELECTION
    start-of-selection.
    read flights
      select * from spfli into table it_spfli.
    display header
      uline (61).
      write: /     sy-vline no-gap,
              (3)  'Flg'(001) color col_heading no-gap, sy-vline no-gap,
              (4)  'Nr'(002) color col_heading no-gap, sy-vline no-gap,
              (20) 'Von'(003) color col_heading no-gap, sy-vline no-gap,
              (20) 'Nach'(004) color col_heading no-gap, sy-vline no-gap,
              (8)  'Zeit'(005) color col_heading no-gap, sy-vline no-gap.
      uline /(61).
    display flights
      loop at it_spfli.
        write: / sy-vline no-gap,
                 it_spfli-carrid color col_key no-gap, sy-vline no-gap,
                 it_spfli-connid color col_normal no-gap, sy-vline no-gap,
                 it_spfli-cityfrom color col_normal no-gap, sy-vline no-gap,
                 it_spfli-cityto color col_normal no-gap, sy-vline no-gap,
                 it_spfli-deptime color col_normal no-gap, sy-vline no-gap.
      endloop.
      uline /(61).
    tell user what is going on
      call function 'SAPGUI_PROGRESS_INDICATOR'
         exporting
              PERCENTAGE = 0
               text       = text-007
           exceptions
                others     = 1.
    start Excel
      create object h_excel 'EXCEL.APPLICATION'.
    PERFORM ERR_HDL.
      set property of h_excel  'Visible' = 1.
    CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'c:\kis_excel.xls'  .
    PERFORM ERR_HDL.
    tell user what is going on
      call function 'SAPGUI_PROGRESS_INDICATOR'
         exporting
              PERCENTAGE = 0
               text       = text-008
           exceptions
                others     = 1.
    get list of workbooks, initially empty
      call method of h_excel 'Workbooks' = h_mapl.
      perform err_hdl.
    add a new workbook
      call method of h_mapl 'Add' = h_map.
      perform err_hdl.
    tell user what is going on
      call function 'SAPGUI_PROGRESS_INDICATOR'
         exporting
              PERCENTAGE = 0
               text       = text-009
           exceptions
                others     = 1.
    output column headings to active Excel sheet
      perform fill_cell using 1 1 1 200 'Carrier id'(001).
      perform fill_cell using 1 2 1 200 'Connection id'(002).
      perform fill_cell using 1 3 1 200 'City from'(003).
      perform fill_cell using 1 4 1 200 'City to'(004).
      perform fill_cell using 1 5 1 200 'Dep. Time'(005).
      loop at it_spfli.
    copy flights to active EXCEL sheet
        h = sy-tabix + 1.
        if it_spfli-carrid cs 'AA'.
          perform fill_cell using h 1 0 000255000 it_spfli-carrid.
        elseif it_spfli-carrid cs 'AZ'.
          perform fill_cell using h 1 0 168000000 it_spfli-carrid.
        elseif it_spfli-carrid cs 'JL'.
          perform fill_cell using h 1 0 168168000 it_spfli-carrid.
        elseif it_spfli-carrid cs 'LH'.
          perform fill_cell using h 1 0 111111111 it_spfli-carrid.
        elseif it_spfli-carrid cs 'SQ'.
          perform fill_cell using h 1 0 100100100 it_spfli-carrid.
        else.
          perform fill_cell using h 1 0 000145000 it_spfli-carrid.
        endif.
        if it_spfli-connid lt 400.
          perform fill_cell using h 2 0 255000255 it_spfli-connid.
        elseif it_spfli-connid lt 800.
          perform fill_cell using h 2 0 077099088 it_spfli-connid.
        else.
          perform fill_cell using h 2 0 246156138 it_spfli-connid.
        endif.
        if it_spfli-cityfrom cp 'S*'.
          perform fill_cell using h 3 0 155155155 it_spfli-cityfrom.
        elseif it_spfli-cityfrom cp 'N*'.
          perform fill_cell using h 3 0 189111222 it_spfli-cityfrom.
        else.
          perform fill_cell using h 3 0 111230222 it_spfli-cityfrom.
        endif.
        if it_spfli-cityto cp 'S*'.
          perform fill_cell using h 4 0 200200200 it_spfli-cityto.
        elseif it_spfli-cityto cp 'N*'.
          perform fill_cell using h 4 0 000111222 it_spfli-cityto.
        else.
          perform fill_cell using h 4 0 130230230 it_spfli-cityto.
        endif.
        if it_spfli-deptime lt '020000'.
          perform fill_cell using h 5 0 145145145 it_spfli-deptime.
        elseif it_spfli-deptime lt '120000' .
          perform fill_cell using h 5 0 015215205 it_spfli-deptime.
        elseif it_spfli-deptime lt '180000' .
          perform fill_cell using h 5 0 000215205 it_spfli-deptime.
        else.
          perform fill_cell using h 5 0 115115105 it_spfli-deptime.
        endif.
      endloop.
    EXCEL FILENAME
      CONCATENATE SY-REPID '_' SY-DATUM6(2) '_' SY-DATUM4(2) '_'
                  SY-DATUM(4) '_' SY-UZEIT '.XLS' INTO FILENAME.
      CALL METHOD OF H_MAP 'SAVEAS' EXPORTING #1 = FILENAME.
      free object h_excel.
      perform err_hdl.
          FORM FILL_CELL                                                *
          sets cell at coordinates i,j to value val boldtype bold       *
    form fill_cell using i j bold col val.
      call method of h_excel 'Cells' = h_zl
        exporting
          #1 = i
          #2 = j.
      perform err_hdl.
      set property of h_zl 'Value' = val .
      perform err_hdl.
      get property of h_zl 'Font' = h_f.
      perform err_hdl.
      set property of h_f 'Bold' = bold .
      perform err_hdl.
      set property of h_f 'Color' = col.
      perform err_hdl.
    endform.                    "FILL_CELL
    *&      Form  ERR_HDL
          outputs OLE error if any                                       *
    -->  p1        text
    <--  p2        text
    form err_hdl.
      if sy-subrc <> 0.
        write: / 'OLE-Automation Error:'(010), sy-subrc.
        stop.
      endif.
    endform.                    " ERR_HDL
    regards,
    venkat

  • RE: Ole Automation with forte.

    Tran,
    Here is a piece of code(using Forte Version 3OF2 & Word 97) that we've
    used to determine if there is already an instance of Word running:
    // Create an instance of a Word Application and activate it.
    // If an a Word application exists, just activate it.
    if ( aTasks <> NIL and aTasks.Exists(aWordApplication.Name) )
    then
    aWordApplication.visible = TRUE;
    aWordApplication.Activate();
    else
    aWordApplication = new();
    aTasks = new();
    aWordApplication.CreateUsingProgID( 'word.application'
    aWordApplication.visible = TRUE;
    aWordApplication.Activate();
    aTasks is an attribute of type Tasks on our window & aWordApplication is
    an attribute of type _Application on our window. This code will work if
    there already is an instance of Word that was started from a Forte
    applicaiton. It doesn't recognize a instance of Word that was started
    outside of a Forte app. Hope this helps!!
    From: Quy Tran[SMTP:[email protected]]
    Sent: Wednesday, May 20, 1998 11:17 PM
    To: [email protected]
    Subject: Ole Automation with forte.
    Good Day forte users,
    I'm trying to invoke MSWord from a forte application.
    I set the objectreference using CreateUsingProgId(This is the only way
    that I could get it to work).
    The problem is when using CreateUsingProgId, forte will create another
    instance of Word. Is there a way to know if the instance already
    exists
    and retrieve the objectreference of that instance?
    Any help would be appreciated.
    Thanks
    Quy Tran
    Lumley Technology
    Analyst/Programmer
    [email protected]
    Ph : 612 93186722
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive
    <URL:http://pinehurst.sageit.com/listarchive/>
    If you are not the intended recipient, please notify the Sender.
    Non-business opinions may not reflect opinions of Piper Jaffray

    Hi Aurang
    You can call almost all methods using OLE. What is required is to know how to interpret a script to ABAP OLE call. This is explained in the tutorial<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c1d54348-0601-0010-3e98-bd2a2dcd9e6c">"An Easy Reference For OLE Automation"</a>
    Regards
    *--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

Maybe you are looking for

  • How to stop the v3 jobs?

    how to stop the v3 jobs?

  • Wrong Selection Screen

    Hi, I am facing a very weird problem. When i try to open a query with user id TEST1, the BEx is showing selection pop-up from some other query. I then do a cancel but immidietly after that the correct selection pop-up comes up. I then give the select

  • Hi I just lost my brand new laptop in a taxi. Can it be tracked? Thanks.

    Hi I just lost my brand new laptop in a taxi. Can it be tracked? Thanks.

  • .avi's in final cut pro

    I got some AVI files that I can't open in FCP. don't know the codec, but i can open them in the VLC media player. This doesn't do me much good as far as getting them edited. If anyone can help, then thanks in advance

  • Motorola Surfboard 5101 Cable Modem

    I just wanted to post a message about my findings and my solution to the Mototrola SurfBoard 5101 Cable modem. I use comcast as my ISP. I was using an old COM21 modem. I was getting around 4300 KBPS on a broadband test from Speakeasy. Since Comcast w