Automatic creation of MS Word Documents within a Report

Dear Experts,
within my report which creates automatically activities in a background process I have to create MS Word Documents and
attach this Word Documents to the Activity.
The Word Document does have a Logo and the text is changing with every Activity created.
What would be the best technical solution for the creation of this word documents for my report?
Best Regards
Oliver

Hello, I have found out what was the problem. In the end I have used method EDITREPLACE and not WW2_EDITREPLACE and I put the method EDITREPLACE more to the end of my ABAP Code:
REPORT  z_prueba_oliver.
TYPES: BEGIN OF ty_partner,
             nif            TYPE bu_partner,
             name_org1      TYPE bu_nameor1,
             conting_com    TYPE c LENGTH 2,
             fecha_efecto   TYPE zbufecha_ef,
             END OF ty_partner.
DATA:  lt_partner1     TYPE TABLE OF ty_partner,
             ls_partner1     TYPE ty_partner,
             lv_file_save_as TYPE c LENGTH 40,
             lv_contador     TYPE n LENGTH 3.
* Include necesario para la declaracion de objetos OLE2
INCLUDE ole2incl.
* Declaraciones para la llamada a WORD.
DATA zword TYPE ole2_object.
CLEAR zword.
ls_partner1-nif = 'X7510034M'.
ls_partner1-name_org1 = 'Razon Social 1'.
APPEND ls_partner1 TO lt_partner1.
ls_partner1-nif = 'X7510034M'.
ls_partner1-name_org1 = 'Razon Social 2'.
APPEND ls_partner1 TO lt_partner1.
ls_partner1-nif = 'X7510034M'.
ls_partner1-name_org1 = 'Razon Social 3'.
APPEND ls_partner1 TO lt_partner1.
ls_partner1-nif = 'X7510035M'.
ls_partner1-name_org1 = 'Razon Social 4'.
APPEND ls_partner1 TO lt_partner1.
ls_partner1-nif = 'X7510035M'.
ls_partner1-name_org1 = 'Razon Social 5'.
APPEND ls_partner1 TO lt_partner1.
LOOP AT lt_partner1 INTO ls_partner1.
  AT FIRST.
    CREATE OBJECT zword 'WORD.BASIC'.
* Se abre el fichero que contiene la plantilla de la carta
    CALL METHOD OF zword 'FILEOPEN'
      EXPORTING
      #1 = 'C:DOCSPRUEBA_1.DOC'.
  ENDAT.
* Se selecciona todo el texto del archivo PRUEBA_1.DOC
  CALL METHOD OF zword 'EDITSELECTALL'.
* Se copia el texto seleccionado al portapapeles
  CALL METHOD OF zword 'EDITCOPY'.
* Se crea un documento nuevo, al que WORD llama documento1
  CALL METHOD OF zword 'FILENEW'.
* Se pega el texto del portapapeles a documento1
  CALL METHOD OF zword 'EDITPASTE'.
* Posicionar al principio del documento
  CALL METHOD OF zword 'STARTOFDOCUMENT'.
* Posicionar al principio del documento
  CALL METHOD OF zword 'STARTOFDOCUMENT'.
* Se selecciona todo
  CALL METHOD OF zword 'EDITSELECTALL'.
* Se borra la selección
  CALL METHOD OF zword 'EDITCLEAR'.
* Se incorpora el texto original de PRUEBA_1.DOC
  CALL METHOD OF zword 'EDITPASTE'.
*IF ls_partner1-conting_com is initial.*
   *CALL METHOD OF zword 'EDITREPLACE'*
    *EXPORTING*
    *#01 = '#linea2y3#'*
    *#02 = 'de la cobertura de Accidentes de Trabajo, de los siguientes código de cuenta de cotización (CCC):'*
    *#03 = 0*
    *#04 = 0*
    *#05 = 0*
    *#06 = 0*
    *#07 = 0*
    *#08 = 0*
    *#09 = 0*
    *#10 = 1*
    *#11 = 0*
    *#12 = 1.*
*else.*
     *CALL METHOD OF zword 'EDITREPLACE'*
    *EXPORTING*
    *#01 = '#linea2y3#'*
    *#02 = 'de la cobertura de Accidentes de Trabajo y Contingencias Comunes, de los siguientes código de cuenta de cotización (CCC):'*
    *#03 = 0*
    *#04 = 0*
    *#05 = 0*
    *#06 = 0*
    *#07 = 0*
    *#08 = 0*
    *#09 = 0*
    *#10 = 1*
    *#11 = 0*
    *#12 = 1.*
*ENDIF.*
  *CALL METHOD OF zword 'EDITREPLACE'*
    *EXPORTING*
    *#01 = '#codprov#'*
    *#02 = ls_partner1-nif*
    *#03 = 0*
    *#04 = 0*
    *#05 = 0*
    *#06 = 0*
    *#07 = 0*
    *#08 = 0*
    *#09 = 0*
    *#10 = 1*
    *#11 = 0*
    *#12 = 1.*
  CALL METHOD OF zword 'EDITREPLACE'
    EXPORTING
    #01 = '#nomprov#'
    #02 = ls_partner1-name_org1
    #03 = 0
    #04 = 0
    #05 = 0
    #06 = 0
    #07 = 0
    #08 = 0
    #09 = 0
    #10 = 1
    #11 = 0
    #12 = 1.
* Se reemplaza el campo #nomprov# con el valor de la tabla interna.
  CALL METHOD OF zword 'EDITREPLACE'
    EXPORTING
    #01 = '#FECHA_EFECTO#'
    #02 = '10 de Junio de 2010'
    #03 = 0
    #04 = 0
    #05 = 0
    #06 = 0
    #07 = 0
    #08 = 0
    #09 = 0
    #10 = 1
    #11 = 0
    #12 = 1.
  lv_contador = lv_contador + 1.
  CONCATENATE 'C:DOCS' 'PRUEBA' lv_contador '_' sy-datum '.DOC' INTO lv_file_save_as.
* Se cierra el documento activo, documento1 con opción de salir sin salvar
  CALL METHOD OF zword 'FILESAVEAS' EXPORTING #1 = lv_file_save_as.
* Se cierra el documento activo PRUEBA.DOC con opción salir sin salvar
  CALL METHOD OF zword 'DOCCLOSE' EXPORTING #1 = 2.
  AT LAST.
*   Se cierra WORD
    CALL METHOD OF zword 'APPCLOSE'.
*   Se libera el objeto ZWORD
    FREE OBJECT zword.
  ENDAT.
ENDLOOP.

Similar Messages

  • Create PDF from a Word document within Acrobat

    Hi!
    I am having trouble to create a PDF from a Word document within Acrobat itself, and not by using PDF Maker in Word. When I try to create a PDF using Acrobat, it gives me the choice to choose any Office format file, but Word format doesn't appear. I can convert from an Excel document or a PowerPoint document, but not from a Word document, even if Word 2010 is installed and works perferctly. Why?
    I know I can make a PDF in Word itself by printing to the Adobe PDF printer or by using PDF Maker, but I want to resolve the issue in Acrobat that prevents me to select a Word document in the Create PDF dialog window. You can see the dialog box in the screenshot attached.
    Any help would be appreciated.
    I am using Acrobat X version 10.1.8 on Windows 7 Home Premium and I have Office 2010 installed (with Word 2010).

    Thanks for your reply. PDF Maker works in all of my Office applications. However, in Acrobat, the file formats available for me to create PDF from figure all the Office file formats except the one for Word. This is not normal. At my school, Acrobat X and Office 2007 are installed, and I can use there both PDF Maker in Word and creating PDF from Word document within Acrobat.
    So I think maybe there's a key in my Windows registry that is not set correctly? or something like that. I repaired the installation of Office 2010, and I did so for Acrobat X too, but it doesn't help. Any idea of how I can resolve that?

  • Acrobat won't convert Word documents within the Acrobat program

    I am running OS 10.5.2 on my MacBook Pro. I also have Microsoft Office 2004. I just installed Acrobat 8.0 Pro, patched it all up from the downloads on the website and was ready to convert some Word documents that I have to give to my boss. Went through Acrobat and it gives me the following error message:
    "Acrobat could not open 'Dissertation-1.1.doc' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded).
    To create an Adobe PDF document, go to the source application. Then print the document to Adobe PDF or use the Acrobat toolbar found in Microsoft Office applications."
    The file was not an attachment and I don't think it is damaged (or at least I hope not). I can make the PDF document in Word or any of the other Office apps with the tool bar or the PDF printer with Distiller but eventually I'm going to have to combine everything and just thought it would be easier to work through Adobe.
    Has anyone else had this problem or has come about at a solution for converting within Adobe? I might just be missing something obvious but I would appreciate any help that anyone can give. Thanks!

    It was telling you actually what you needed to do.
    Go into word2004 open the document and to Page setup and choose Adobe Printer. Then go to Print menu and choose print File. Then name the file and select desired location.
    What actually happens is acrobat will create a hidden .ps File and check it. (up to 3 times if needed) before writing the hidden.ps file. The Distiller is open in Background hidden and converts the .ps file to a PDF file the file is checked and retried up to three times if something isn't right. Then The Pdf file is written to disk finally the hidden .ps file is deleted and the pdf file appears.
    If your still using 2004 a little icon may show up in word called pdfmaker. This is a little VBA script that does the equivent of above. however its ver slow and if you have a long document your hair may turn gray before it finishes.
    In Office2008 for Mac VBA is dead and laid out in its coffin with its arrival. so PDFMaker is a useless piece of code. Thankfully going into menu view options unchecking PDFMaker actually does banish it from the screen and does don't try to get reinserted if you banish it.
    By the way because of the new XML Based Code in Office2008 they have a word to PDF Translator built in just go to Save As... and scroll down until you see PDF.

  • How to Convert a Word Document within BDN to PDF file

    Hi All,
    Currently, we have word documents stored within the business document navigator (Transaction OAOR) for our Materials.  We want to be able to share these documents with our customers through a Web Interface such as Web Dynpro; however, we need to convert them to a PDF file first.  Currently, we are obtaining the document contents in order to convert the word document to Binary.  A Sample of this code is listed below.  From this point, we are hoping to convert to PDF; however we are uncertain of how to do this.  Is there a standard function module or class that will perform this conversion of a Word document.  Any help will be greatly appreciated.  Thanks.
    *Get Information For BDS Form
      gs_doc_signature-prop_name = 'DESCRIPTION'.
      gs_doc_signature-prop_value = 'Description of Document'.
    *Create BDS Instance
    DATA gr_bds_instance TYPE REF TO cl_bds_document_set.
      IF gr_bds_instance IS INITIAL.
        CREATE OBJECT gr_bds_instance.
      ENDIF.
    *get the Document Contents
      CALL METHOD gr_bds_instance->get_info
        EXPORTING
          classname           = gc_docclass  "BOR Object BUS1001
          classtype           = gc_classtype  "BO for Business Object
          object_key          = gv_objkey      "Material Number i.e. 000000000010034717
        IMPORTING
          extended_components = gt_extended
        CHANGING
          components          = gt_doc_components
          signature           = gt_doc_signature
        EXCEPTIONS
          nothing_found       = 1
          error_kpro          = 2
          internal_error      = 3
          parameter_error     = 4
          not_authorized      = 5
          not_allowed         = 6.
    *Build the Object ID in order to Convert the Word Document to Binary
      READ TABLE gt_extended INTO gs_extended INDEX 1.
      gv_object_id-class = gs_extended-class.
      gv_object_id-objid = gs_extended-objid.
    *Convert the Word Document to Binary Format
      CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'
        EXPORTING
          object_id                 = gv_object_id  "
      CLIENT                    = SY-MANDT
          raw_mode                  = 'X'
        TABLES
      FILE_ACCESS_INFO          =
          file_content_binary       = gt_binary
    *Convert to PDF!?!?!?!?
    John

    Hi
    Refer this thread [Convert MS Word .doc to PDF;
    Regards
    Raj

  • Automatic creation of FI & Co Documents

    Hi All SD Gurus
    I want to block the automatic creation of Accounting (FI) and Controlling (CO) documents when I create a Billing Document (F2). Can anybody help me in blocking this automatic creation ? I will do 'Release to Accounting' by selecting the Billing Documents by VF04.
    Thanks & Warm Regards

    Dear Anil,
    As suugested by others, it is Billing Block in Billing Type configuration, which will not allow automatic posting to FI. T.Code fr Billing Type Configuration is VOFA.
    Regards,
    Rajesh Banka

  • Including a Word document within a SAPscript?

    We currently have a SAPscript that pulls a text document from document
    management and prints it in the middle of  a SAPscript.
    Does anyone know if there is a way I could do the same thing with a Word document instead?  If so, please let me know if there is a way to do it.
    Thanks.
    Mike

    Hi
    This link will help you in your requirement
    Printing documents - document management
    Regards
    Raj

  • How can I select pages to print from a Word document using the report generation 'print report' vi?

    I have researched the knowledge base and found:
    Printing A Range of Pages or Number of Copies of a Report Using the Report Generation Toolkit in LabVIEW.
    This seems to be from a previous version of LV. I am using LV2010. The instructions given do not match up with the current vi. The information did provide a tip and drilling down into  the vi I was able to insert the from/to page numbers at the printout invoke method, however this prevents the print function from working in that it can no longer find the default printer.
    The error message is:
    Error 1015 occurred at NI_ReportGenerationToolkit.lvlib:Word_Print.vi -> NI_Word.lvclassrint Report.vi ->
    error 1015 is: Printer is not responding. Check printer configuration.
    Any ideas how I can make the modification to print, for example, pages 24 through 29 out of a 32 page word document?
    Thanks,
    Chris

    Hello, take a look at this article. Unfortunately the Generate Report Get Data to Modify.vi was remove since RGT 1.1.3 release. That being said, we can try to find a workaround. See "Configuring a Printer Through the Windows Dialog in LabVIEW", open the GetPrinterSettings.vi, at the PrinterSettings property node you can select the from/to page. I hope this helps.
    Alejandro | Academic Program Engineer | National Instruments

  • How to save Charts to a word document using LabVIEW Report Genereration toolkit?

    I just started using the LabVIEW Report Genereration toolkit, but I can't figure out how to save Waveform Charts (one dimensional data versus time, instead of Graphs) to a Word document. Can somebody give a suggestion? Thanks!

    Nina,
    In MS Word, you have 2 options when you select Insert Object:
    Microsoft Excel Chart
    Microsoft Graph 2000 Graph
    If you select Insert Picture, you can choose Chart. This is the same chart as when you select Microsoft Excel Chart.
    To insert this chart, you will use Word Insert Graph.vi. This VI calls Word_Insert_Chart.vi, that uses ADO object Graph.Chart and its properties and methods.
    From the Microsoft Help:
    Create a chart by using Microsoft Graph
    When you create a chart by using Microsoft Graph, a chart and its associated data are displayed in a table called a "datasheet."
    Zvezdana S.
    National Instruments

  • Font problem creating WORD document with Oracle Reports 8i/9i

    I created a report using different Arial fonts. Once the report is generated from a .NET application, the fonts in the word document are changed apparently into Helvetica. This disarrange my lay-out completely. How can I solve this problem?
    (NB. when I generate a PDF, there is no problem!)

    By the way. I create the files in this way:
       private void createFile(String outFileName) {
          try {
             ByteArrayInputStream result = clientDoc.getPrintOutputController().export(ReportExportFormat.PDF);
             File newFile = new File(outFileName);
             FileOutputStream output = new FileOutputStream(newFile);
             int bytesRead = 0;
             byte[] byteArray = new byte[10000];
             while ((bytesRead = result.read(byteArray)) != -1) {
                output.write(byteArray, 0, bytesRead);
             output.flush();
             output.close();
          } catch (Exception e) {
             e.printStackTrace();

  • Embedding DMS Documents within CG42 Report Template

    Hi All,
    We are using EH&S and DMS and would like to combine these two into a CG42 report template.  Through CG02, we have created specifications where we would like to have some value assignments instances take advantage of the user-defined text tab to pull in documents from DMS.  We have configured the system to successfully link in the DMS document info record into the user-defined tab within the value assignment area of CG02 and can view the DMS documents by double clicking on that reference.
    In taking this to the next step, we would like to embed this document into our report template definition.  Mind you that some of these documents are .pdf containing text and graphics.  Within CG42, we go to the specification symbol that we want and open the area called ADDITIONAL INFO, which then opens to other symbols, one of which is "ESTDF Additional Information - User-Defined Text".   When we open that node, it provides us with many attributes as options that we can embed within the report template.  The only one that relates to content is "GESTDHEADE HEADER Start of UD Text ".  It appears that all this does is just repeat the link that was specified in CG0 when we use the command to include that in the report template and then do a preview on the report.
    In reading some SAP Help Documentation in the section for user-defined text, I'm led to believe that you can embed these into the report template but I have not been able to do so thus far.  The only thing I can do is embed information about the user-defined text into the report template.
    Can someone shed some light if this is feasible?
    By the way, we are already embedding graphic logos by relating it to a phrase and keeping these images in a folder on a file server.  If we must, we can use that approach but I'd really lile to keep these documents in DMS as a controlled document.
    Thanks!

    Hello
    please consult online help. Take a look here:
    http://help.sap.com/saphelp_erp60_sp/helpdata/en/a7/2872ac0a6c11d28a220000e829fbbd/content.htm
    Chapter: Symbol Type: Specification
    Subchapter: Output of Document Management Documents
    The description is ok and in my opinion a good starting point.
    Hope this helps.
    C.B.
    PS: http://help.sap.com/saphelp_erp60_sp/helpdata/en/a7/286d780a6c11d28a220000e829fbbd/content.htm is helpful too.
    Chapter: User-Defined Texts and Documents
    Edited by: Christoph Bergemann on Nov 26, 2011 5:12 PM

  • Automate creation of Intercompany billing document

    Hello All,
    We have a requirement to automate the intercompany billing document to be created whenever F2 billing document is created ( without using VF04).
    Any input regarding this will be greatly appreciated.
    Thanks,
    Nagaraju

    After goods issue has taken place, you can process the delivery for billing. You can create the billing documents just like any other billing document on the Billing screen:
    for a single billing document with the menu path Billing document ---Create.
    for several billing documents with the menu path Billing document -
    Billing due list.
    The delivery may have to be processed for billing twice.
    The delivering plant processes the delivery to create an intercompany billing document (billing document type IV) for the selling company. This company code posts invoice entry for this billing document.
    The billing document is automatically billed to the internal payer that is assigned to the sales organization. The intercompany charges that appear in the intercompany billing
    document represent the actual amount that the delivering plant is charging the sales organization.
    If the selling company is selling the goods to a customer, it processes the delivery to create an invoice for this customer. The system can take the prices from the order or determine new prices. It takes the quantity to be invoiced from the delivery.
    The billing due list for the intercompany invoice is generated after the customer invoice has been created.

  • Automatic creation of Follow-up document

    Hi,
    I have a requirement to create a sales order automatically from a quotation once the status of the quotation is changed to 'released'.
    Can I use any standard SAP defined actions to achieve this functionality?
    If there is no standard actions defined for this; can you suggest a solution with minimal customization or may be changing any existing defined actions?
    Best Regards,
    Kunal

    Hi Kunal
    SAP Standard workflow should be able to handle this for you.
    Regards
    Arden

  • How do i change a pdf in preview to a word document in pages?

    Does anyone know how i return to work on a word document within pages as i'm currently viewing it as a pdf in preview.

    Preview does not have that capability. Go to MacUpdate or CNET Downloads and search for software that can do such a conversion.

  • Linking word document to report and refreshing

    I'm looking to link word documents to a report. After changing the word documents I'm looking for a way to automatically refresh WITHOUT opening the report again.
    I know this can be done if the report is opened after changing the word documents but I'm trying to find a way to do it without re-opening.
    Is there a way?
    Slim

    Hi Slim,
    If you are not refreshing your report, it will show only static information which is saved in your previous refresh.  It is not possible to view changes without refreshing the report.
    Thanks,
    Sastry

  • Embedding Word Document into Microsoft Web Browser

    Dear sirs,
    My purpose is to embed a word document within a windows form.
    For this purpose, I have used the following references:
    http://support.microsoft.com/kb/304643
    http://support.microsoft.com/kb/982995#FixItForMeAlways
    The word file opened successfully within the browser, and everything worked correctly.
    One problem remains, whenever I open another word document , or just lunch a new instance of MS-Word,
    the ribbon within the browser becomes disabled.
    Your help is much appreciated.

    Dear sirs,
    My purpose is to embed a word document within a windows form.
    For this purpose, I have used the following references:
    http://support.microsoft.com/kb/304643
    http://support.microsoft.com/kb/982995#FixItForMeAlways
    The word file opened successfully within the browser, and everything worked correctly.
    One problem remains, whenever I open another word document , or just lunch a new instance of MS-Word,
    the ribbon within the browser becomes disabled.
    Your help is much appreciated.
    If you embed word with IE and open another word document, the same result?
    That should be the common behavior of IE(somehow equals webbrowser)
    remember make the reply as answer and vote the reply as helpful if it helps.

Maybe you are looking for

  • What are the ideal/optimum settings for the Airport Express for WiFi... ?

    I currently have my MacPro plus my MacBook Pro running from my Airport Express and they work perfectly... but my new iPhone 4 won't see the network... does anyone know why this could be and is it something to do with security or other setting I have

  • Can Bridge report in-camera settings for White Balance?

    No matter what settings I choose in Bridge Preferences, I cannot get it to tell me what was the White Balance (WB) setting of the camera when raw images were shot. This seems an odd omission because Camera Raw is passed this information and displays

  • Cyrillic fonts fo FCP

    I've bought my iMac and FCE in Russia and Cyrillic fonts were pre-installed in my computer. In few days I will have to edit on Mac Book Pro that my client brings from UK. He told me that the computer has no Cyrillic fonts. But we will need to make Ru

  • Lost wireless IP address when synching apple TV

    I loose the IP address and access to internet on my wireless time machine. It happens every time I try to synch large files from my computer to my apple TV through iTunes. Internet connection is reestablished after a power reset of the Time Machine,

  • Lion-Windows users cannot see attachments

    I just upgraded to Lion, and now some Windows users cannot see/find attachments. I did all that was advised (clicking on the "Windows user friendly" list), but to no avail. I sent to several Windows users and no one can see attachments with the new M