Creating Macros in MS word from ABAP

How to create a macro in MS word from ABAP code.I want to generate tables dynamically in Word using Macro from the data generated by the code.
Regards,
Sinu.

Hi Mathew
Better is create a macro in MS Word and calling the macreo frol ABAP.
Check my macros below.
1. A macro to create a table
Public Function CreateTables(Rows As Integer, Cols As Integer, Width1 As Double, _
                             Width2 As Double, Width3 As Double, Width4 As Double, _
                             Width5 As Double, Width6 As Double, Width7 As Double)
' CreateTables Macro
' Macro created 2007-06-11 by WINUEL SA
    Dim oRange As Word.Range
    Dim oTable As Word.Table
    Set oRange = ActiveDocument.Bookmarks("bmT01").Range
'   Add table to range of bookmark (oRange)
    Set oTable = ActiveDocument.Tables.Add(Range:=oRange, _
    NumRows:=Rows, _
    NumColumns:=Cols, _
    AutoFitBehavior:=wdAutoFitFixed)
    ActiveDocument.Tables(1).Columns(1).Width = CentimetersToPoints(Width1)
    ActiveDocument.Tables(1).Columns(2).Width = CentimetersToPoints(Width2)
    ActiveDocument.Tables(1).Columns(3).Width = CentimetersToPoints(Width3)
    ActiveDocument.Tables(1).Columns(4).Width = CentimetersToPoints(Width4)
    ActiveDocument.Tables(1).Columns(5).Width = CentimetersToPoints(Width5)
    ActiveDocument.Tables(1).Columns(6).Width = CentimetersToPoints(Width6)
    ActiveDocument.Tables(1).Columns(7).Width = CentimetersToPoints(Width7)
End Function
2. A macro to fill table
Public Function FillTabRowNo2(RowNo As Integer, S1 As String, S2 As String, S3 As String, _
                             S4 As String, S5 As String, S6 As String)
    ActiveDocument.Tables.Item(1).Cell(RowNo, 1).Range.Text = RowNo
    ActiveDocument.Tables.Item(1).Cell(RowNo, 1).Range.Paragraphs.Alignment = Alig2
    ActiveDocument.Tables.Item(1).Cell(RowNo, 2).Range.Text = S1
    ActiveDocument.Tables.Item(1).Cell(RowNo, 3).Range.Text = S2
    ActiveDocument.Tables.Item(1).Cell(RowNo, 4).Range.Text = S3
    ActiveDocument.Tables.Item(1).Cell(RowNo, 5).Range.Text = S4
    ActiveDocument.Tables.Item(1).Cell(RowNo, 5).Range.Paragraphs.Alignment = 2
    ActiveDocument.Tables.Item(1).Cell(RowNo, 6).Range.Text = S5
    ActiveDocument.Tables.Item(1).Cell(RowNo, 6).Range.Paragraphs.Alignment = 2
    ActiveDocument.Tables.Item(1).Cell(RowNo, 7).Range.Text = S6
    ActiveDocument.Tables.Item(1).Cell(RowNo, 7).Range.Paragraphs.Alignment = 2
End Function
best regards
John

Similar Messages

  • How to select a bookmark in Word from abap?

    Hi,
    We are looking for a way to select a specific bookmark from a Word document (opened before from abap, using methods of class I_OI_DOCUMENT_PROXY). The bookmark needs to be replaced by a specific value.
    We tried call method 'execute macro' .... with par1 = '-1' and parm4 = 'GoTo'. The retcode is OK, but nothing happens. Any ideas what we are missing here?
    Regards,
    Hans van der Kooij

    Thanks Jayanthi,
    We had already read the article, but did not interpret it correctly. We found the solution in an SAP OSS note.
    We had to use method get_document_handle to get an OLE link and continue from there with OLE. The article however is very brief on that part and has no example.
    So for anyone who would like to do the same or simular:
    - call method do_document->get_document_handle:
        EXPORTING
           no_flush = ''
        IMPORTING
           error = do_error
           handle = do_handle
           retcode = do_retcode.
    - GET PROPERTY OF do_handle-obj 'Application' = do_ole_application.

  • Create EJB and call it from ABAP

    Hi all,
    I have written a stand-alone-Java application, which should be converted into a web application, which has no gui.
    This application should be triggered by a abap-program.
    Following questions, do I have to write a servlet and a ejb or is it possible to call the ejb directly from the abap-program?
    What do I have to do make an outbound call from abap?
    Thank you for your support.
    Kind regards, Patrick.

    Hi.
    You can call the EJB directly from Abap. XI uses this functionality extensively.
    Follow these steps:
    1)  Deply the bean on the java stack.
    2)  You now need to setup a RFC destination in the JCO RFC Provider service in the j2ee visual adminstrator. Point the Repository section to the application server you want to run the Abap reort on. When you do this the j2ee engine will register itself as a possible RFC destination on this application server.You can choose your own program id...
    3) You then need to goto tran sm59 on the app server where the Abap report is going to run and setup a connection of tcp type to the j2ee machine. Specify the same program id you used in step in the technical settings.
    4) Then just use the bean name when you do the rfc call in the abap report.
    Hope this helps if U have not done it yet.

  • Is it able to create a local dict. structure from abap-ddic information?

    hi,
    i try to import an abap-ddic structure to my local java dictionary. How is this possible? Or is it only possible to create an structure via an rfc-import?
    how can i create a structure automatically as it is in abap without using a corresponding rfc?
    kr, achim

    I did a couple of previous iterations where I Reader-enabled the form, but I did not do that on this form, nor did I set any sort of security on the document.  I imported the document from Word, added text fields, changed formatting on the fields, and some other basic things, then saved and exited.  I went back into the form to test, filled out the necessary fields, signed using my signature (which prompted me to 'Save As' a different file name), I printed the document, then attempted the Distribute.  The dialog opened and allowed me to enter email addresses of those to whom I wish to send the document.  At this point, I attempted to use both Acrobat.com and my own personal email box on separate occasions to compile the test responses.  After everything was set, I tried to send it to my recipients, and that is when I get the error messages.

  • Creating a text file output from ABAP

    Hi
    I'm trying to create a comma delimited text file by using ABAP code
    Could someone please help me with my coding in the following areas or is there better coding to do it:
    1)Is there a way  to move the entire Customer file KNA1 into my text file instead of doing it field by field.
    2)How can I do the comma seperation correctly?
    REPORT  ZTEXTFILE.
    data: lt_kna1 type table of kna1.
    data: ls_kna1 type kna1.
    data: lv_filename type string value 'ztest.txt'.
    select * from kna1 into table lt_kna1.
    open dataset lv_filename for output in text mode encoding default.
    IF sy-subrc <> 0.
      WRITE :/ 'ERROR'.
      EXIT.
    ENDIF.
    loop at lt_kna1 into ls_kna1.
    transfer ls_kna1-kunnr  to lv_filename.
    transfer ';' to lv_filename.
    transfer ls_kna1-name1 to lv_filename.
    transfer ';' to lv_filename.
    endloop.
    close dataset lv_filename.
    WRITE :/ 'DONE'.
    Many thanks
    Gerhard

    REPORT ZTEXTFILE.
    data: lt_kna1 type table of kna1,
            ls_kna1 type kna1,
            lv_filename type string value 'ztest.txt',
            lv_file type string.
    select * from kna1 into table lt_kna1.
    open dataset lv_filename for output in text mode encoding default.
    IF sy-subrc ne 0.
    WRITE :/ 'ERROR'.
    EXIT.
    else
    loop at lt_kna1 into ls_kna1.
    CONCATENATE ls_kna1-kunnr ls_kna1-name1 into lv_file separated by ','.
    transfer lv_file to lv_lilename.
    clear lv_file.
    endloop.
    close dataset lv_filename.
    endif.
    WRITE :/ 'DONE'.
    Try this out, should do the trick. Also, may i suggest not using '*' in your select statement and fetch data only for the fields you wish to have in your text file after filtering using a where Claus. It would greatly improve performance.
    Edited by: AJ Nayak on Feb 9, 2012 11:05 AM

  • Creating datetime in XML format from ABAP

    Hello All:
         I have a ABAP program that creates an XML file and everything is fine. I just need one date field in XML to conform to W3CC standard (EX: 2006-12-01T10:53:05.2170000). I need datetime in the format "2006-12-01T10:53:05.2170000". How do I acheive this in ABAP?
    Thanks.
    Mithun

    That seems to be easy:
    DATA:
      lv_timestamp  TYPE timestampl,
      lv_xml_date   TYPE string.
    GET TIME STAMP FIELD lv_timestamp.
    CONCATENATE lv_timestamp+0(4)
                lv_timestamp+4(2)
                lv_timestamp+6(2)
      INTO lv_xml_date
      SEPARATED BY '-'.
    CONCATENATE lv_xml_date
                'T'
      INTO lv_xml_date.
    CONCATENATE lv_timestamp+8(2)
                lv_timestamp+10(2)
                lv_timestamp+12(2)
      INTO lv_xml_date+12(8)
      SEPARATED by ':'.
    CONCATENATE lv_xml_date
                lv_timestamp+5(7)
      INTO lv_timestamp
      SEPARATED BY '.'.
    Reward points, if reply is applicable
    Edited by: Mike Schernbeck on Jan 30, 2008 9:24 PM

  • Create and open Crystal Reports from ABAP program

    Hello,
    Let me explain the scenario with a simple example.
    In my ABAP program, I have the entries of table MARA in an internal table. I want to now create a crystal report through ABAP, and display the result in a .rpt file programatically.
    Could you please provide some pointers?
    Regards,
    Suraj

    Hi,
    I think this can done through the BW development or we can use the XI.
    Pls refer to this link
    Crystal reports
    Thanks & Regards,
    Chandralekha.

  • Creating certificates in ms word from sap hr om

    hi everybody , i did program for creating training certificates for attendees of otype E and relation A025 in hrp1001.i used ole for that,but i need to make border lines and logo at bottom in certificates,i used one logic for logic ,i.e GET PROPERTY OF gs_actdoc 'InlineShapes' = gs_inlineshapes.
    CALL METHOD OF gs_inlineshapes 'AddPicture' = gs_logo
      EXPORTING
      #1 = 'C:\logo.bmp'
      #2 = 0
      #3 = 10.
    CALL METHOD OF gs_actdoc 'SaveAs'
    exporting
         #1 = v_filename.
    *call method of gs_word 'Quit' .
      FREE: gs_word, gs_actdoc, gs_documents, gs_newdoc.
      endform.but i am using this the logo is coming in top of the page in ms word,same as the file in .bmp, which i saved in c directory. but the logo should come at bottom and how to code for borders through ole please respond very urgent.

    hi everybody , i did program for creating training certificates for attendees of otype E and relation A025 in hrp1001.i used ole for that,but i need to make border lines and logo at bottom in certificates,i used one logic for logic ,i.e GET PROPERTY OF gs_actdoc 'InlineShapes' = gs_inlineshapes.
    CALL METHOD OF gs_inlineshapes 'AddPicture' = gs_logo
      EXPORTING
      #1 = 'C:\logo.bmp'
      #2 = 0
      #3 = 10.
    CALL METHOD OF gs_actdoc 'SaveAs'
    exporting
         #1 = v_filename.
    *call method of gs_word 'Quit' .
      FREE: gs_word, gs_actdoc, gs_documents, gs_newdoc.
      endform.but i am using this the logo is coming in top of the page in ms word,same as the file in .bmp, which i saved in c directory. but the logo should come at bottom and how to code for borders through ole please respond very urgent.

  • Creating an xml file from abap code

    Hello All,
    Please let me know which FM do I need to execute in order to create an XML file from my ABAP code ?
    Thanks in advance,
    Paul.

    This has been discussed before
    XML files from ABAP programs

  • Create XML file from ABAP with SOAP Details

    Hi,
    I am new to XML and I am not familiar with JAVA or Web Service. I have searched in SDN and googled for a sample program for creating XML document from ABAP with SOAP details. Unfortunately I couldn't find anything.
    I have a requirement for creating an XML file from ABAP with SOAP details. I have the data in the internal table. There is a Schema which the client provided and the file generated from SAP should be validating against that Schema. Schema contains SOAP details like Envelope, Header & Body.
    My question is can I generate the XML file using CALL TRANSFORMATION in SAP with the SOAP details?
    I have tried to create Transformation (Transaction XSLT_TOOL) in SAP with below code. Also in CALL transformation I am not able to change the encoding to UTF-8. It's always show UTF-16.
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
      <xsl:template match="/">
        <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
          <SOAP:Header>
            <CUNS:HeaderInfo>
              <CUNS:InterfaceTypeId>10006</InterfaceTypeId>
              <CUNS:BusinessPartnerID>11223344</BusinessPartnerID>
              <CUNS:SchemaVersion>1.0</SchemaVersion>
              <CUNS:DateTime>sy-datum</DateTime>
            </CUNS:HeaderInfo>
          </SOAP:Header>
          <SOAP:Body>
            <xsl:copy-of select="*"/>
          </SOAP:Body>
        </SOAP:Envelope>
      </xsl:template>
    </xsl:transform>
    In ABAP program, I have written below code for calling above Transformation.
      call transformation ('Z_ID')
           source tab = im_t_output[]
           result xml xml_out.
      call function 'SCMS_STRING_TO_FTEXT'
        exporting
          text      = xml_out
        tables
          ftext_tab = ex_t_xml_data.
    Please help me how to generate XML file with SOAP details from ABAP. If anybody have a sample program, please share with me.
    Is there any easy way to create the XML file in CALL Transformation. Please help.
    Thanks

    Try ABAP forum, as it seems not to be PI related.

  • I am trying to create a print ready PDF from a word file with unacceptable results.

    I am trying to create a print ready PDF from a word file with unacceptable results.
    The word file has a trim size of 6” x 9”. It has been set to mirror margins with the inner, top and bottom margins set to 0.75”, the outer margin is set to 0.5” and the gutter to 0.14”.
    It doesn’t matter if I create the PDF from inside Word, or open Acrobat Pro 11.0.9 and click Create From File, while the resulting document size is correct and the odd numbered pages reflect the correct margins, the even numbered pages do not. This results in some text near the outer margin, as well as the page numbers being omitted.
    Does anyone know how to correct this?
    I just noticed that some of the odd numbered pages' text is also cropped. Apparently Acrobat is refusing to set side margins to smaller than 1" (@ 3cm).

    I'm away from my printer, so I'll try it later. Even so, the proposed test is irrelevant. I operate a small publishing house and am trying to upload certain novels to Ingram, the largest book distributor in the world. The specifications I've set are the specifications they've asked for. Since they've said that the results I'm obtaining are unacceptable, and since they demand submission in PDF form, this renders Acrobat Pro for Mac completely unacceptable for anyone in the publication industry. As far as I can tell, Adobe has a serious bug here that it needs to fix—and at once.

  • How to translate the key words in ABAp program from lower case to upper cas

    How to translate the key words in ABAp program from lower case to upper case?

    Hi Kittu,
    You need to set the Pretty Printer settings to achieve key words in ABAP program from lower case to upper case.
    Utilities -> Settings -> Pretty Printer (tab) -> Select third radio button.
    Thats all.
    <b>Reward points if this helps.
    Manish</b>

  • Using Crystal Report to create reports from ABAP

    Hello,
    We are currently using Jetform as the designer for our outputs like Invoice, Order confirmation, etc.....
    We would like to switch to Crystal instead, but don't really know where to start from.
    - We already have crystal on our B/W instance
    - The additional need for Crystal is in R/3, and would be triggered trough ABAPs.
    What I am looking for. I guess, is the equivalent to when:
    we call up smartforms from ABAP using the generated function modules
    we call up sapscript from ABAP using the predefine function call (write_form open_form close_form, etc)
    we call up Jetform using special control code along with the data, sent to a jetform configured printer
    => What kind of call would we then make to send data to Crystal Reports place holder and print them?
    => What kind basis set-up is needed to have to comunication between Crystal and SAP established?
    Thank you in advance for yours hints

    Hi,
    You will likely be able to access the tables directly using the Opensql driver using Crystal Reports.  I don't understand why you are assuming that an Infoset is necessary.  Can you point me to the documentation that states that an Infoset is necessary?
    In any case, if you want to create an Infoset, this is done in SQ02.  You need to make sure that you belong to a user group in order for Crystal Report to see the infoset.

  • Custom Spell Check from ABAP Code without MS Word

    Hi All,
    I am working on a requirement where we need to check for misspelt words in a string that is received from another system. I have come across a number of FM's which can be used to check for spellings but all of the require MS Word to be installed in our PC, but I am looking for a solution that does not involve MS Word. If any of you have come across any external tool that can be called from ABAP code or any suggestion on a logic that can be built please pass it on. Any pointers or help in this regard would be highly appreciated.
    Thanks,
    Praveen

    Hi,
    Try the "CF_WWSpeller" customtag which actually uses the
    Winword spelling engine,
    http://web4w3.com/wwspeller.html

  • Create an SAP Web Service Consumer (calling External Sharepoint Web Service from ABAP)

    hi all,
    i am trying to
    Create an SAP Web Service Consumer (calling sharepoint Web Service from ABAP) using blog given on following link
    Create an SAP Web Service Consumer (calling External Web Service from ABAP) 
    but when i am using my url at the end of step 3, i am getting error as follows:
    i dont want to use local file option. Can anyone help me in this??
    thanks in advance
    regards,
    SDS

    Hi SDS,
    you recieved a http 404 error when trying to access the Sharepoint Web service. Http 404 indicates that the resource is not reachable (cf. HTTP 404 - Wikipedia, the free encyclopedia). There could be different reasons for that. I'd suggest rubble checking the URL of the Web service first. Try to access it from a browser on you desktop. If the URL is correc. Most likely the SAP system is not able to connect to the URL. This could, for example, be due to some firewall restrictions. You should ask a SAP Basis colleague if they are able to access the URL of the Web service from the server on which the SAP system is running.
    Christian

Maybe you are looking for

  • Extending isight NEED PRO HELP PLAESE!!! Haven't found answer anywhere yet

    ok, I know you guys can do this... c'mon- please help. I am trying to run close to 50-60 feet of firewire over to where my LCD TV is located to power my isight camera from my Mac Mini and am having problems. It was suggested that I buy (5) "IEEE-1394

  • Using the new iMovie and importing pictures from iPhoto, why are some of my pictures blurry?

    I Know this topic has been discussed before, but I couldn't find anything recent about this.  I have iMovie opened & I'm putting the pictures in. In iPhoto the pictures are clear, but when moved to iMovie, become blurry. I know it has to do with the

  • How to read or write cookies within Applets?

    To make a session between an Applet and a Servlets I want to read and write cookies with an Applet. Does anyone know if an Applet is allowed to read and write cookies? And how to make it?

  • Shutdown takes to long

    Since I updated to 10.5.4 I realized that the shutdown sequence on my MacPro executed much slower than before. It takes about a minute to bring it down. My G4 500 Dual Gigabit (which also running Leopard) needs half of the time! First I suspected the

  • Document with all the changes to the JLS introduced by JDK 5.0

    Do you know if there is document with all the Java Language Specification changes introduced by JDK 5.0? I think I've seen such a document somewhere on the java.sun.com website but I can't remember where. I wish there was an updated version of JLS. T