Execute an Excel Macro?

Hello all,
I created a report in which I show the result in an Excel...so far no problem... I open an Excel Template document, I pass the information I want to the places I want etc. The only problem is that I method for executing a macro seems not to work!
Does somebody has an idea whats wrong?
The security for macros in the excel is at medium...I already tried to put the security level to low...but nothing.
The <i>retcode</i> has as result "MACRO_OR_SCRIPT_FAILED"
I created the Macro and I am sure it works...because when I execute it manualy it does what it should do. Even after my report has open the documente and shows the document I can execute de macro and it works.
        call method p_g_document->execute_macro
          exporting
            macro_string = 'COPYSHEET'
          importing
            error        = it_errors
            retcode      = retcode.
Just for information, the only thing the macro does is copying a spreadsheet.
I somebody could help it would be great, I already lost some days to find the solution.
Thanks in advanced.
Marcelo Moreira

Hey all,
Does not seemes that someone has the answer I need, but my last question for this topic is....
Does someone of you already implement a report, using an excel with macro calling from ABAP?
I have doubts if the method
<i>call method I_OI_DOCUMENT_PROXY->execute_macro</i> really work for Excel.
Even in the SAPOFFICEINTEGRATION example I am not sure if it works.
Maybe someone of you has an working example of macro calling from ABAP for Excel.
I would be very glad if somebody has some ideas for my problem....I getting mad with this... :-S
Greetings,
Marcelo Moreira

Similar Messages

  • Execute Excel Macro Through DIAdem

    Hi All,
      I am currently trying to run a script in DIAdem which exports certain material properties to an Excel Macro-enabled workbook.  Inside the Excel workbook the user executes a macro to perform some calculations.  The results of that calculation will then be re-imported into a DIAdem report.  I have the import/export data part down, but the million dollar question is how can I execute an Excel macro from DIAdem's VBScript?
      I know some are going to say this makes no sense, just do the calculation in DIAdem.  I know this, but the file/calculations are an industry accepted toolbox and it must be done this way. 
      Thanks in advance and here is some dumbed down code to showcase the example:
    Option Explicit 'Forces the explicit declaration of all the variables in a script.
    Dim excel
    Dim excelbook
    Dim a
    Set Excel = CreateObject("Excel.Application")
    Excel.Visible = True
    Set excelbook=Excel.Workbooks.Open("My File")
    excelbook.Sheets("InputResults").range("B5").value = Data.Root.ChannelGroups(ChanGrp#).Properties("myProp").Value
    'Call 'My_Macro' !!!!!!!!!!!!!!!!!!!!
    Msgbox("Result is: " & excelbook.Sheets("InputResults").range("B5").value)
    Solved!
    Go to Solution.

    Hi GT_Mark
    You simply can use the methode Run
    Call Excel.Run("MyMacro")
    Of course you have to make sure that you refer only to data that are available in Excel.
    To obtain CodeCompletion for Excel in the script editor select Microsoft Excel x.x Objects Library in the "Registed Type Libraries" dialog box. The x.x value depends on your installed Excel version.  To open this dialog box, select Script»Type Libraries in DIAdem SCRIPT.
    Hope this helps
    Winfried

  • Executing Excel Macros from SAP

    Hi all Experts,
    I have created a program which tranfers data from different internal tables into Different Worksheets of a single workbook.
    Now, Can some one please tell me how to Execute macros from SAP.
    Regards,
    AJ

    To execute an Excel macro follow these steps.
    1. Create macro inside Excel Workbook where you transferred your information.
    2. Use following instruction to execute the desired macro you create:
        DATA: EXCEL TYPE OLE2_OBJECT.
        CREATE OBJECT EXCEL 'Excel.Application'.
        CALL METHOD OF EXCEL 'Run' EXPORTING #1 = 'WRITE_SHEET_CELL'
                                                                            #2 = 'VALUE1'
                                                                            #3 = 'VALUE2'
                                                                            #4 = 'VALUE3'.
    In previous example, macro WRITE_SHEET_CELL was created first. The macro name must be in uppercase.
    Regards.
    Rafael Rojas.

  • Running Excel macros from ABAP

    Hello everyone,
    I am trying to execute an Excel macro from an ABAP program.  We are currently on a 46C system.  While doing some research on help.sap.com I came across the method execute_macro in class i_oi_document_proxy.  I’ve never used methods in ABAP before and I’m not really sure what I’m doing.  Has anyone got this to work?  When I try to run the program it dumps with error OBJECTS_OBJREF_NOT_ASSIGNED.
    Thanks,
    Becky
    Here is the program:
    REPORT ztest_program.
    INCLUDE ole2incl.
    DATA gs_excel TYPE ole2_object .
    DATA gs_wbooks TYPE ole2_object .
    DATA gs_wbook TYPE ole2_object .
    DATA gs_application TYPE ole2_object .
    DATA: h_sheet TYPE ole2_object.
    DATA: document TYPE REF TO i_oi_document_proxy.
    *Name of the macro in Excel
    DATA: macro_string(50) TYPE c
                     VALUE 'FB03process.FromTheBeginning',
          no_flush TYPE c,
          param_count TYPE i VALUE 0,
          script_name TYPE c VALUE 'X',
          error TYPE REF TO i_oi_error
                OCCURS 0 WITH HEADER LINE,
          retcode TYPE soi_ret_string,
          error_string(50) TYPE c,
          retvalue(30) TYPE c.
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
       EXPORTING
             text       = text-007
         EXCEPTIONS
              OTHERS     = 1.
    CREATE OBJECT gs_excel 'EXCEL.APPLICATION' .
    SET PROPERTY OF gs_excel 'Visible' = 1 .
    GET PROPERTY OF gs_excel 'Workbooks' = gs_wbooks .
    GET PROPERTY OF gs_wbooks 'Application' = gs_application .
    *--Opening the existing document
    CALL METHOD OF gs_wbooks 'Open' = gs_wbook
         EXPORTING #1 = 'D:\temp\FB03process.xls' .
    tell user what is going on
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
       EXPORTING
              PERCENTAGE = 0
             text       = text-009
         EXCEPTIONS
              OTHERS     = 1.
    GET PROPERTY OF gs_excel 'ACTIVESHEET' = h_sheet.
    CALL METHOD document->execute_macro
         EXPORTING macro_string  = macro_string
                   param_count   = param_count
                   script_name   = script_name
                   no_flush      = no_flush
         IMPORTING error         = error
                   retcode       = retcode
         CHANGING  error_string  = error_string
                   retvalue      = retvalue.
    disconnect from Excel
    FREE OBJECT gs_excel.
    PERFORM err_hdl.
    FORM err_hdl.
      IF sy-subrc <> 0.
        WRITE: / 'Fehler bei OLE-Automation:'(010), sy-subrc.
        STOP.
      ENDIF.
    ENDFORM.                    " ERR_HDL

    Hi,
    Please correct me if I am wrong but it seems that you have not fetched a handle to the document object before issuing the statement CALL METHOD document->execute_macro. Hence the error OBJECTS_OBJREF_NOT_ASSIGNED is being dislayed. If you want to use SAP Desktop Office Integration using ABAP Objects, take a look at this article at http://www.intelligenterp.com/feature/archive/ or http://www.sapinfo.net/public/en/index.php4/article/comvArticle-193333c63b4bd807d2/en/articleStatistic
    Hope this helps.
    Regards
    Message was edited by: Shehryar Khan

  • Execute Infopackage Through BAPI Using Excel Macro (BAPI_IPAK_START)

    Hi everyone,
    I have a problem when execute infopackage through BAPI using excel macro. I have create a button in macro. When this button is clicked, BAPI for trigger InfoPackage will executed (BAPI_IPAK_START) and this button will disabled.
    After this process completely done (traffic indicator for the request is green in update rules), the button will enabled again.
    Here the subroutine or pseudocode that i will write :
    Private Sub ClickButton()
    Begin
    1. ThisButton.Activated = False   --> Disabled Button
    2. Call BAPI/custom Function Module to execute InfoPackage (BAPI_IPAK_START)
    4. ThisButton.Activated = True   --> Enabled Button
    End
    The problem is i need some statement like this between statement no 2 and statement no 4
    Statement That I Want :
    3. Wait Until BAPI Execute Completely
    So user can click this button again only after the process is finished completely. I don't know how to do this in macro (in ABAP i know i can use "WAIT ... SECOND"), others said this can be done using event in schedule option at infopackage. Anyone,please help me.
    Thank you.
    Regards,
    Satria B

    Enter that req number in RSRQ and monitor the load
    or  right click on the DS - manage - you will req in yellow status which is in progress and you can click on the ...takes you monitor screen
    Edited by: Srinivas on Jul 6, 2010 7:51 AM

  • Could not connect to Oracle database from excel macro. Getting connection not open.

    Hi all, 
    I could not connect to oracle database using excel macro. After much R&D also, I cannot find right solution. Please help me where I am doing wrong.
    Sub Button2_Click()
    Dim Conn As New ADODB.Connection
    Dim RS As New ADODB.Recordset
    Dim Cmd As New ADODB.Command
    Dim sqlText As String
    Dim Row As Long
    Dim Findex As Long
    Dim Data As Worksheet
    Dim X As Long
    Dim UID As String
    Dim PWD As String
    Dim Server As String
    Dim strCon As String
    Application.Calculation = xlCalculationManual
    UID = "myUserid" 'Enter the User ID
    PWD = "myPassword" 'Enter the password
    Server = "myHostname or myServername" 
    Set Data = Sheets("Sheet2")  
    Data.Select
    Range("A:J").ClearContents 
    strCon1 = "Provider = Microsoft.ACE.OLEDB.12.0;DATA SOURCE=myHostName;Database=myDBname;uid=myUserid;pwd=myPassword;"
    Conn.Open (strCon1)
    Cmd.ActiveConnection = Conn
    Cmd.CommandType = adCmdText
    ' Put your query next
    sqlText = " select * from table "
    Cmd.CommandText = sqlText
    Set RS = Cmd.Execute
    For X = 0 To 17 
    Data.Cells(1, X + 1) = RS.Fields(X).Name
    Next
    Do While Not RS.EOF 'this loops through the data and puts it in the spreadsheet
    Row = Row + 1
    For Findex = 0 To RS.Fields.Count - 1
    Data.Cells(Row + 1, Findex + 1) = RS.Fields(Findex).Value
    Next Findex
    RS.MoveNext
    Loop
    Application.Calculation = xlCalculationAutomatic
    Application.Calculate
    End Sub
    sammy

    I have set oci.dll in to the path specified. Prior to this I musy say that, I have 64 bit excel 2010 & installed respective drivers from the link provided http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html
    But
    still I am facing as:-" Provider cannot be found. It may not be properly installed."
    sammy

  • Excel macro will not run with OLE

    I have an ABAP program which builds an Excel macro with VBA code, downloads the file and inserts it into a new Excel workbook, and then runs the macro to populate the workbook.  All of this is being done via OLE functionality.
    The process works correctly for 99% of our user community.  However, some users are having trouble where when the Run Macro command is executed, the program just hangs and nothing happens.
    Here's a snippet of the code:
      CREATE OBJECT excel 'EXCEL.APPLICATION'.
    Insert macro file into the spreadsheet.
      CALL METHOD OF excel 'Modules' = ole_module NO FLUSH.
      CALL METHOD OF ole_module 'Add' = ole_newmodule NO FLUSH.
      CALL METHOD OF ole_newmodule 'Activate' = ole_activate NO FLUSH.                                              
      CALL METHOD OF ole_newmodule 'InsertFile' = ole_insertfile NO FLUSH EXPORTING #1 = macrofile.                   
      FREE OBJECT ole_insertfile NO FLUSH.                    
      FREE OBJECT ole_activate NO FLUSH.                     
      FREE OBJECT ole_newmodule NO FLUSH.
      FREE OBJECT ole_module.
    Execute the macro(s).
      macro_name = 'load_data_zsddxl'.                        
      CALL METHOD OF excel 'Run' = ole_run EXPORTING #1 = macro_name.                             
      FREE OBJECT ole_run.                                     
    The automation trace gives me this message (sorry about the formatting):
    <26=Automation:    CALL METHOD "Run" OF [#12/0x109B0C4C/101/Excel.Application.14]
                        #0: STRING "load_data_zsddxl"
    <26=Automation(Error):    CALL METHOD "Run"[DispID=259] OF [#12/0x109B0C4C/101/Excel.Application.14]
                        #0: STRING "load_data_zsddxl"
    IDispatch::Invoke raised exceptionThe remote procedure call failed
    <26=Automation(Error):   
    <26=Automation(Error):    ****************************ERROR OCCURED IN MODULE: [Microsoft Excel Application]**********************************************************************************************************************************
    <26=Automation(Error):    PROGRAM_ID               |MODULE_NAME                     |METHOD_NAME             |ERROR DESCRIPTION                    |VERSION            |GUI VERSION               |MODULE_PATH                                 |
    <26=Automation(Error):    **********************************************************************************************************************************************************************************************************************
    <26=Automation(Error):    Excel.Application.14     |Microsoft Excel Application     |Run                     |The remote procedure call failed     |14.0.5138.5000     |Gui Version not found     |C:\PROGRA1\MICROS1\Office14\EXCEL.EXE     |
    <26=Automation(Error):    **********************************************************************************************************************************************************************************************************************
    <26=Automation(Error):   
    What's strange is that if after starting Excel I set the property VISIBLE = '1', everything works as expected.
    The affected users are running on Windows7 with Excel 2010.
    Thanks for any direction you can provide.

    No, I don't.  It's been my understanding that by omitting the "NO FLUSH" from a command, that the accumulated commands are flushed at that point.  But I'll give it a try.  Willing to try anything at this point.
    Thanks.

  • Java Error while executing the excel template in the BIP 10g report server

    Hello Gurus,
    While we are executing the excel template we are getting the following java error and the report cannot be rendered to user who triggers the report. Where as the same excel template is generating output when user run it against the same data locally.
    "oracle.apps.xdo.servlet.scheduler.ProcessingException: [ID:652] Document file to deliver not found : C:\Oracle\bipublisher\oc4j_bi\j2ee\home\applications\xmlpserver\xmlpserver\xdo\tmp\xmlp3307tmp
    at oracle.apps.xdo.servlet.scheduler.XDOJob.deliver(XDOJob.java:1172)
    at oracle.apps.xdo.servlet.scheduler.XDOJob.execute(XDOJob.java:495)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:195)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)"
    We have tried with designing the .rtf template for this report and we are able to generate the report form the server. Please let us know the cause for this error in the server and way to rectify the exception from the report server.
    Thanks,
    Kamath.

    "oracle.apps.xdo.servlet.scheduler.ProcessingException: [ID:652] Document file to deliver not found : C:\Oracle\bipublisher\oc4j_bi\j2ee\home\applications\xmlpserver\xmlpserver\xdo\tmp\xmlp3307tmp
    imho it's about empty result file
    Data are there
    may be yes but is some data from all for report itself ?
    in other words data can be in output ( in xml ) but report can filters data and so report doesn't have appropriate data to representation ( it's assumption for error )
    Data are there, when we are using rtf template, it is generating the output.
    if you sure about data for report and on this data report works fine by bip desktop, so no ideas, only SR
    btw you can first check my assumption and try to catch "no data found" in template
    also you can check data itself, is it well-formed xml

  • How to call excel macros programmatically in C#?

    Hi,
    I have a requirement where i need to call excel (2003) macros in C# program. Can anyone help me with a code snippet to do the same?
    The excel macro function takes two input parameters? how can the parameters be passed?
    Any code snippet to do the same in C# would be helpful.
    Thanks.

    Hey there, Sid.  I am tryin gto run your code, but I couldn't even gte it to fire.  Here's what I ahve now:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Excel = Microsoft.Office.Interop.Excel;
    namespace WindowsFormsApplication2
        public partial class Form1 : Form
            private void button1_Click(object sender, EventArgs e)
                //~~> Define your Excel Objects
                Excel.Application xlApp = new Excel.Application();
                Excel.Workbook xlWorkBook;
                //~~> Start Excel and open the workbook.
                xlWorkBook = xlApp.Workbooks.Open("C:\\Users\\Ryan\\Desktop\\Coding\\Microsoft Excel\\Work Samples\\Work Samples\\Historical Stock Prices.xlsb");
                //~~> Run the macros by supplying the necessary arguments
                xlApp.Run("ShowMsg", "Hello from C# Client", "Demo to run Excel macros from C#");
                //~~> Clean-up: Close the workbook
                xlWorkBook.Close(false);
                //~~> Quit the Excel Application
                xlApp.Quit();
                //~~> Clean Up
                releaseObject(xlApp);
                releaseObject(xlWorkBook);
            //~~> Release the objects
            private void releaseObject(object obj)
                try
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
                    obj = null;
                catch (Exception ex)
                    obj = null;
                finally
                    GC.Collect();
    When I hit the play button nothing happens.  When I hot F5 nothing happens.  Do you ahve any idea what I'm doing wrong.  I'd appreciate any advice with this!! 
    Thanks!!
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

  • Excel macro error after deploying in Weblogic

    Halo,
    I have written excel macros and it is working fine.
    but if the same file if i try to open from hyperlink after deploying in Weblogic server , I get the error
    "error occured initializing the VBA libraries.
    If Microsoft Visual Basic for Applications (VBA) was not installed, or was set to Install on first use,
    (advertised, or set to install on demand) you may receive this error message.
    Depending on the mode of installation used and the rights of the user to change current settings,
    it is possible to install VBA through Control Panel, Add/Remove Programs, Microsoft Office, Add or Remove
    features. If Visual Basic for Applications is not listed as an installable feature of Office, the administrator
    of your system may have disabled it so it is impossible for you to install it. If VBA is not installed,
    it is impossible to run VBA applications/projects on this computer. "
    1. Even though Excel VBA application is installed in my machine , why am i getting this error.??
    2. I would like to know is there any way to open the excel file even though if the excel software is not installed in client machine??
    Appreciate your help.
    Thanks.

    Hi,
    I do not see any reason for this to not work.
    Is there any difference between the preferences for RX and RXI. Please go to "edit" -> "Preferences" -> "Security(Enhanced)" and uncheck "Enable protected mode at startup".
    Are you able to open any pdf from command line with the same command:
    "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"  <<PDF_FILE>>
    Thanks,
    Amish.

  • Using Excel macros & change properties

    Hi,
    1) my program use Excel macro via a runtime.exec(cmd). I want to use JWS to deliver new versions of application but if I have to put my macros in a jar file how can I reach them (no problem with a file propertie or with gif ressources).
    2) how can I change default properties ("Dossier des applications" in French maybe Applications dir in advanced) wich is enabled in the window.
    thanks a lot
    Sophie

    1) my program use Excel macro via a runtime.exec(cmd).
    I want to use JWS to deliver new versions of
    application but if I have to put my macros in a jar
    file how can I reach them (no problem with a file
    propertie or with gif ressources).You have a lot of options how to do this.
    I would try to use the I/O APIs that reads the macro file
    from a web server (InputStream is = url.openStream()) and put it
    in a local file (FileOutputStream = new FileOutputStream(file)).
    Of course you would need a local location where to store it, could
    be hardwired, or asked from the user.
    2) how can I change default properties ("Dossier des
    applications" in French maybe Applications dir in
    advanced) wich is enabled in the window.I do not understand what you want to do. Explain again.
    Regards,
    Marc

  • How do I make an Excel macro and Labview push to copy Labview calculated data into a cell on demand?

    Hey there, I am a chemist so Labview and programming aren't exactly my strong point. 
    We have a Labview program that we run to control and automated valve manifold that has a thermocouple and pressure transducer that displays the temperature and pressure on the "front panel" of the labview file we run.  The temperature and pressure of the manifold changes in real time while the labview is running.  We must attach a sample to the manifold, take the pressure and temperature, then record those values in an excel spread sheet, one at a time.
    What I would like to do is make a key board macro in excel to automatically type in the current read out of the temperature (and another for pressure) into which ever selected excel cell you are on, so that you don't have to switch back to the labview window to look at it.  I have a very basic understanding of macros in VB but I don't know how to get the labview to make the read outs available for the excel macros to find it.
    Thanks for the help, Here is a screen shot of the block layout of the program.
    Attachments:
    back.JPG ‏79 KB

    Why not have LV put the data in Excel for you?  You can use Actvie X to do this.  There is plenty of information on the forum and knowledge base on how to use Active X and reporting to Excel.  Plus you have the example finder.  Do you have the Report Generation Toolkit?  LV7 is quite old, so I don't know if this is an option for you.
    Reese, (former CLAD, future CLD)
    Some people call me the Space Cowboy!
    Some call me the gangster of love.
    Some people call me MoReese!
    ...I'm right here baby, right here, right here, right here at home

  • 'Edit in Place' for XLSM-files (Excel Macro-Enabled)

    Hi,
    is it possible to activate 'Edit in Place' for xlsm-files (Excel Macro-Enabled Workbook file)?
    For xls(x)-files there is the link 'Edit This File', but not for files of type 'xlsm' allthough they could be dealt the same way with Excel.
    I know I can edit this files using the 'Add-in for MS Office' and via the 'Vibe Desktop', but it would be nice to deal them like other Excel-files.
    thx
    Martin

    Originally Posted by mschuhmann
    RTFM helps I admit:
    Novell Vibe 3.3 Administration Guide > Site Setup > Setting Up Site-Wide Customizations > Configuring File Associations for Edit in Place Applications
    Novell Doc: Novell Vibe 3.3 Administration Guide - Configuring File Associations for Edit in Place Applications
    Append ".xlsm" for the variable edit.in.place.file.applet.extensions, edit.in.place.file.webdav.extensions
    Hi Martin,
    Yeah, the Vibe docs can help on occasion
    Still, thanks for feeding it back to the forums as it can be quicker finding a hit in the forums than having to go through the docs!
    Cheers,
    Willem

  • Export to Excel - Macro problems

    I have moved this to the Discoverer forum. Exporting to Excel - Macro Problems
    Message was edited by:
    user385142

    Hello Denes.
    Excuse me for send you a message in this way , but I dont find other way to contact with you.
    Im using the export_excel_pkg, and really it work good.
    I have only one problem, I tell you.
    When, in one item, data is very long and numeric, by example a EAN code, without any class of format, by default it give me the value ###, Im studing the package and trying to resolve this, but if you can send me any idea it can help me a lot.
    Thanks in advanced.
    You are doing a great work for us.

  • Excel macro on SharePoint 2013

    Hi,
    I know that SharePoint doesn't support Excel macro but in the next future will it change anything?
    Thanks

    Hi,
     I don't think so it may happen. May be in next release of SharePoint version we can expect some extra features like this. Let's wait and see
    Sekar - Our life is short, so help others to grow
    Whenever you see a reply and if you think is helpful, click "Vote As Helpful"! And whenever
    you see a reply being an answer to the question of the thread, click "Mark As Answer

Maybe you are looking for

  • Shared Services is taking forever to come up

    Hello Experts, One of my customer has an issue with Shared Services. They have intergrated Shared Services with Active Directory and want to pull users into a SS from a specific AD group. Right now its pulling all the users but Shared Services is tak

  • Batch conversion of CR2 to JPG

    I am trying to automate a batch conversion of CR2 files to jpg files in Photoshop CS4.  I have converted them to dng.  When I open them in CS4, it opens the Canon photo editor, but will not record the actions. Is there another way to automate this? 

  • Arranging iphoto albums

    How do I arrange the albums in chronological order instead of alphabetical. I accidentally changed it to alphabetical and can't figure out how to change it back!!! thanks

  • Directory browsing mechanism in Oracle Reports

    Hello, Is there a way in Oracle Reports to implement a directory brower for a system / user parameter. I.e. could on browse the OS for pathnames/filenames, and have them filled in the e.g. DESNAME parameter. The purpose would be that users may browse

  • Help me with IOS 5

    How do i update my itouch to IOS 5! i can't find it on itunes! Help!