Ole for excel 2007 SAVEAS failing

Hi!
Am using abap+ole and code snippet below is failing; am using Excel 2007 in compatibility mode.
I just want to save the spreadsheet as a new name.
Really would appreciate your insights!
Thanks!
Jim
parameters: p_file type localfile default 'C:\temp\zz.xls'.
data: g_new type localfile value 'c:\temp\zzzzzzz.xls'.
data: e_work  type ole2_object.
call method of e_work 'SAVEAS'
          exporting
                    #1 = g_new.
(returns subrc = 2)

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

Similar Messages

  • Does anyone know how to hide the export option for excel 2007

    Does anyone know how to hide the export option for excel 2007?
    We are having an issue with negative numbers downloading as text field in excel 2007, works fine in excel 2003.
    We are on version 11.1.1.7.0 of OBIEE.
    Thanks for any response.

    Go to iTunes>Preferences>Devices and highlight the backup you want to delete and click on Delete Backup

  • Error running XL Reporter: 'a required COM add-in program..' for Excel 2007

    I have 2 users running Excel 2007 that can't run XL reporter.  They get the message 'a required COM add-in program for XL Reporter has not been loaded'.  I have instructions for Excel 2003, but not for 2007.  Does anyone know how to resolve this for Excel 2007?

    Gordon,
    I have instructions to get the IXXLReporter.dll file in the installation area, but 2007 has completely different layout. I can't find where to go???  Can you please give me the procedure?
    Edited by: Pat Frohlich on Apr 1, 2009 10:12 AM

  • I attempted to download a "critical" update for Excel, however, it failed.  When I try and open an excel doc I am not able to ~ can anyone help???

    Hello - I attempted to download a "critical" update for Excel, however, it failed.  I shut down the computer.  Now I am not able to access docs in excel either ones I have already created or create new ones.  I continue to get an error message.  Please help!!!!!  thanks!!

    I suspect you may want to try Microsoft's Mac Office support forums, since this appears to be an issue with their software. 
    What error message (if any) do you get if you try and start up Excel?
    However, if it happened to me I'd probably remove Office and then resintall it from the original disks.  That will take you back to the original shipping version of Office after which it should update you to the latest version.
    Most likely when Microsoft's update software failed it managed to corrupt the Excel program files in such a way that they are no longer usable.  So a resintallation of the program is likely the only real option to fix this one.

  • Which TDM Addin for Excel 2007?

    I downloaded what I think is the latest TDM add-in for excel 2007.  When I go to open my file a message comes up saying that my file has more than 65000 rows.  I know the limitation is not in excel 2007.  Will the add-in only load 65000 rows of data? 

    Frank,
    So the installation of the addin went smoothly?  You did not have to add it in manually like in this KB?
    http://zone.ni.com/devzone/cda/tut/p/id/5885
    You may want to check the specs on the trial version of excel 2007 that you have.  Did you get this from the web?  I don't know if Microsoft would do this, but sometimes the trial software won't have all of the features of the full version.  I just installed the addin on my machine with full version of excel 2007 and was able to open a TDM file with a million random numbers stored in it. 
    A good way to test this would be to just create a spreadsheet file with 100,000 numbers in it, then try to open that in excel just to see if it throws the same error.  That would eliminate the possibility of the addin being to blame.  If the file opens without error, then you may want to check that the addin was installed correctly by referencing the KB linked above.
    Have a great day.
    Brian Coalson
    Software Engineer
    National Instruments

  • GW 8.0.1 Excel 2007 Save As gives unreadable spreadsheet

    Hi,
    We're testing a Win 7 machine with Office 2007 on our GW 8.0.1 HP1 system and have come across a strange issue.
    If we open an existing GroupWise Excel 2003 document, edit it and then choose Save As -> New Document back into GroupWise the document which goes into GroupWise has been given an xlsx document type (Excel 2007) even though the document is still in 2000/3 format. This means that the document fails to open as it is in the 'wrong' format for Excel to understand.
    If we edit the DMS document properties and change the extension to xls from xlsx then the document will open fine.
    Is this a known issue? Is there any workaround? At the minute I've asked the user to use the copy document function in GroupWise before opening the document but when Office 2007 is rolled out properly this is bound to come up again.
    TIA,
    Mark.

    Anyone else had this problem? Or is it just me? Can't believe no else has tried this on Windows 7 and Office 2007.
    Mark.

  • Regd: BEE Spreadsheet Interface for Excel 2007

    Hi All,
    After accesing the BEE Spreadsheet Interface function it prompts me to download file. After allowing the download file.. it opens up an excel sheet prompting for WEB_ADI[1].xls to be downloaded on the system.
    the it says Processing: Create Document. Your document is being created. Do not close this window until processing completes.
    The excel sheets gets struck at this point. it does not download the file..
    I have also changed the Excel 2007 Trust center options and enabled Trust access to VBA objects and Enable all macros.
    My profile options are set as
    BNE UIX Base Path : /OA_HTML/cabo/
    BNE UIX Physical Directory : /u02/oratrng/trnmlgappl/html/cabo/
    Can someone guide if i am still missing any setups or options..................
    Thanks in advance,
    Prashanth

    Hi,
    OK fine the sheet got dowloaded now.. But after that i am facing a new problem ..after i enter the details in Excel and try ot upload thm it gives me error : Connection to the server is unavialable. This is a common error, so please check the BNE.log file for details about the error.
    You may also review these documents and see if any is applicable.
    Note: 553134.1 - The Connection To The Server Is Unavailable When Uploading Journals From Webadi
    Note: 553851.1 - Webadi Upload Fails In RAC Environment; Message: The Connection To The Server Is Unavailable
    Note: 394680.1 - Error -The Connection to the Server is Unavailable When Upload Web ADI - Interface Columns Integrator
    Note: 361944.1 - The Connection To The Server Is Unavailable When Uploading Journals From WebADI
    Note: 334632.1 - Web ADI Create Document Fails - Connection to The Server is Unavailable Error on Worksheet
    Note: 419995.1 - WebADI Upload ''Connection To The Server Is Unavailable'' While Uploading
    Note: 428643.1 - CONNECTION TO SERVER ERROR DURING UPLOAD OF MORE THEN 144 LINES
    Note: 847091.1 - Error 'The Connection To The Server Is Unavaiable' when Uploading WEB ADI Document
    Note: 359584.1 - Webadi Cannot Upload Adi Spreadsheet (The Connection To Server Is Unavailable.)
    Note: 329926.1 - BNE.D Web ADI Letters Fail to Export Download is an Empty Document - Spreadsheet
    Note: 271811.1 - Connection Unavailable Error Occurs When Uploading Files In Web Adi
    Regards,
    Hussein

  • Showing Zero values in OLAP Pivot Table for Excel 2007

    Hello,
    I needed a help to a problem. Is it possible to show the values with No sales in an Olap Pivot Table ??
    I have a sales Cube, and brwsing it via excel i wanted to filter on a Product Category and see how many products in this category had made no Sales. By default the Pivot table doesn't shows the empty values, so if i check the Showm empty rows option for
    Pivot Tables, i see the whole of the products populated with and without sales, and i can't filter further. Is there a way i can only get those which have no sales.
    Vinish Viswanathan

    Happy Holidays,
    I can slice on product categories in Excel 2013 with these settings for the Pivot Table:
    Activate "Show items with no data for rows and columns"
    Apply a value filter that says that the measure should filter on values = 0
    Have the product natural hierarchy on rows with levels product category->subcategory->product.
    Expand the levels below product category
    Use the product category attribute and not the hierarchy as the filter.
    I do not have Excel 2007 installed anymore.
    HTH
    Thomas Ivarsson

  • Patch level for Excel 2007 (Release 640)

    Hi!!!
    Do you know which patch level is necessary for the interaction between SAP and Excel 2007??
    We have pach level 22 and when we try to download some ALV using the button "Microsoft Excel", SAP opens a page of Excel without information.
    Thanks a lot!
    Lluís i Montse

    Hello
    Check your macro settings in Excel 2007.
    1)  Open Excel
    2)  Click on the round office button at the top left of the window
    3)  Click Excel Options at the bottom
    4)  Choose Trust Center on the left
    5)  Click the Trust Center Settings button
    6)  Click Macro Settings on the left
    7)  Choose "Disable all macros with notification"
    8)  Click OK, then Click OK again
    When you try your ALV again, it should ask you if you want to Enable the macro, click Enable then it should work.
    Hope this works for you
    Reid Maulsby

  • Save as dialog window for excel file save ....

    hi!
    i have a jsp that displays all the report names to the clients and when clicked on the report downloads an excel file and saves to the client machine.this is accomplished by calling a servlet that sets the content type as "application/octet-stream" and setting the header as "setHeader("Content-Disposition", "attachment; filename=myExcel.xls")
    and writing the bytes to the excel file.works just perfect.
    now if you open the excel file and make changes to it and try to save it with a different name by clicking 'save as' option from file menu, the 'save as file type' by default shows "text" instead of excel worksheet.
    have you guys come across this problem anytime....
    kindly let me know you have any suggestions ..
    thanks in advance,
    /rahul

    one more point:
    the save as list box displays "myExcel.xls"(with quotes) where it should have displayed simply myExcel.

  • Converting A PDF to excel 2007 failed

    Converting a PDF bank Statement to Excel 2007 format failed.  Help

    Hey Joseph,
    Please tell me whether you are able to convert any other PDF file to excel format or not?
    What exact error message do you get?
    Are you trying to convert a scanned PDF document?
    Hope to hear from you.
    Regards,
    Anubha

  • Excel 2007 to Sql server table. Column with more than 255 characters.

    Hi there,
    I am facing a problem while converting data from Excel 2007 to SQL server 2005 table. I am using BIDS 2005.I have an excel file where one particular column has more than 255 characters. I use OLEDB connection for excel file as there is no driver for Excel
    2007 in BIDS2005. I am using Microsoft Office 12.0 Access Database Engine OLE DB Provider for Excel file.
    Next, I changed advanced properties for the column to DT_NTEXT. But when I am getting errors on execution. They are:
    [OLE DB Source [1949]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E21.
    [OLE DB Source [1949]] Error: Failed to retrieve long data for column "action".
    [OLE DB Source [1949]] Error: There was an error with output column "action" (2046) on output "OLE DB Source Output" (1959). The column status returned was: "DBSTATUS_UNAVAILABLE".
    [OLE DB Source [1949]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.  The "output column "action" (2046)" failed because error code 0xC0209071 occurred, and the error row disposition on "output column "action"
    (2046)" specifies failure on error. An error occurred on the specified object of the specified component.  There may be error messages posted before this with more information about the failure.
    Please advise on how can I deal with columns having more than 255 characters in Excel file.
    Thanks!

    Here is what your connection string should look like for excel source
    Provider
    =Microsoft.Jet.OLEDB.4.0;Data
    Source=c:\temp\test.xls;Extended
    Properties="EXCEL 8.0;HDR=YES";
    http://sqlworkday.blogspot.com/

  • How to make restoration of corrupted excel 2007 file?

    Hi there, 
    When I open an excel file the following error message is displayed: “The file may be corrupted, located on a server that is not responding, or read only”.
    Since this happened whenever I open any excel file, the above error message is again displayed, I must also mention that I am sure my files are not read-only and the files are stored on my hard disk and I use VM ware and my OS is windows server! 
    How can I solve this problem?

    You may copy the file to another computer with Excel installed, and open it. If the error still exist, then your file is corrupt. Otherwise, there may be some problems with your Excel in the original computer and you need to uninstall/reinstall Excel.
    If the file is corrupt, then you can try several methods to recover it:
    1. First of all, you can try to repair the file manually in Excel, as follows:
    (1) On the File menu, click Open.
     (2) In the Open dialog box, select the file you want to open, and click the arrow next to the Open button.
     (3) Click Open and Repair, and then choose which method you want to use to recover your workbook.
    You may find more information about this at:
    http://office.microsoft.com/en-us/ex...001034656.aspx (for Excel 2003)
     http://office.microsoft.com/en-us/ex...017.aspx?CTT=1 (for Excel 2007)
     http://office.microsoft.com/en-us/ex...840.aspx?CTT=1 (for Excel 2010)
     http://office.microsoft.com/en-us/ex...554.aspx?CTT=1 (for Excel 2013)
    2. If method 1 fails, there are still several methods to recover your Excel file manually with Excel, including writing a small VBA macro, as below
    http://office.microsoft.com/en-us/ex...#_Toc337637262
    3. Third, there are also free tools from third-parties that can open and read Microsoft Excel files, for example,
    3.1 OpenOffice at http://www.openoffice.org. This is a very famous open source project that is designed to support Office file formats, including Excel files. The software can run under Windows.
    3.2 KingSoft Spreadsheets at
    http://www.kingsoftstore.com/office/free-excel. This is a free Windows tool that can open Excel files.
    3.3 Google Drive at https://drive.google.com/ also support to load Excel files.
    Sometimes when Excel fails to open your file, these tools may be able to open it successfully. If that is the case, then after the Excel file is opened, you can just save it as a new file which will be error-free.
    4. For xlsx files, they are actually a group of files compressed in Zip file format. Therefore, sometimes, if the corruption is only caused by the Zip file, then you can use Zip repair tools such as WinRAR at
    http://www.rarlab.com to repair the file, as follows:
    4.1 Assuming the corrupt Excel file is a.xlsx, then you need to rename it to a.zip
    4.2 Start WinRAR, go to "Tools > Repair Archive" to repair a.zip and generated a fixed file a_fixed.zip.
    4.3 Rename a_fixed.zip back to a_fixed.xlsx
    4.4 Using Excel to open a_fixed.xlsx.
    There may still be some warnings when opening the fixed file in Excel, just let ignore it and Excel will try to open and repair the fixed file. If the file can be opened successfully, then you can just save the contents into another error-free file.
    5. If all above methods do not work, then you may try third-party tools such as DataNumen Excel Repair at
    http://www.datanumen.com/excel-repair/
    I have used it to recover some Excel files successfully. It provides a free demo version so that you can try to see if the data you want can be recovered or not.
    Good luck!

  • Excel 2007 and Smart View 9.3.1.4.041

    Dear Experts,
    We are now working with Excel 2007 and Smart View 9.3.1.4.041, and encounter the problem that ervery time open the protected excel file there would be the warning message "Drawing Objectes in one or more sheet(s) in the workbook are protected. Please unprotect them and try to save again."
    Can any one suggest with;
    1. How to set the Excel security settings for Excel 2007 to work for smart view?
    2. How to avoid the message mentioned above while working with Excel 2007?
    3. How to create a protected Excel file to work with Smart View 9.3.1.4.041 both in Excel 2003 and Excel 2007?
    Tks
    Edited by: Moonlight on May 19, 2010 10:00 AM

    I've experiencied similiar problems, though other users may have found a better solution, I've unlocked the spreadsheat, refreshed, and then relocked via a VBA macro. A button object at the top of the spreadsheet was added to make it easier for the users use as well. If there is a better solution I am very interested in this as well.
    JTF

  • Errors opening Excel 2007 spreadsheets in Excel 2010

    When I try to open spreadsheets created in Excel 2007 with Excel 2010, I get the error:  "Excel found unreadable contenct in 'file name'.  Do you want to recover the contents of this workbook?  If you trust the source of this workbook, click
    Yes".  Then a Repairs dialog box comes up saying:  "Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.    Removed Part: Print options."  File then opens fine. 
    We receive Excel 2007 from various sources.  One of my problem is that we are just starting to migrate people to Windows 7 and Office 2010, with most people still on Office XP.  The file format converter for Excel 2002/2003 does not work with these
    Excel 2007 files.  The other problem is that we have macros that are used to open Excel files and import data into other Excel files.  Pretty hard to modify these macros to allow for some files that are going to pop up this error, and others that
    do not.
    What is causing this problem, and what fix is available?  We have asked that people save the Excel files in Excel 97-03 format before sending to us, with mixed results. 

    Hi,
    Thank you for using Excel IT Pro Discussions forum. 
    Are you using Office 2010 RTM version? If it is trial version or beta version, I suggest upgrading it to the RTM version.
    First, please check if this KB article helps:
    Error message when you try to open a workbook in Excel 2007: "Excel found unreadable content in Book_Name"
    http://support.microsoft.com/kb/929766
    Note: The steps are for Excel 2007. The steps in Excel 2010 are similar.
    If the problem persists, let’s also check the following settings in Excel 2010.
    ========
    1.      
    In Excel 2010, click File > Options > Trust Center > File block settings.
    2.      
    Check the checkboxes before:
    Excel 2007 and later Wordbooks and Templates
    Excel 2007 and later Macro-Enabled Workbooks and Templates
    Excel 2007 and later Add-in Files
    Excel 2007 and later Binary Workbooks
    Then, try to open the Excel 2007 file in Excel 2010 and check the results again.
    Best Regards,
    Sally Tang
    TechNet Subscriber Support
    in forum
    If you have any feedback on our support, please contact
    [email protected]  

Maybe you are looking for