Exporting Reports from Navision to Microsoft Word

hdhd Member Posts: 7
edited 2008-12-01 in Navision Attain
Does anyone know if there is a way to print out Sales documents in Microsoft Word from within Navision? I would like the print functionality of Navision to export a document or text file that can be opened in Word. Ideally, I would like to import the document into Microsoft Word and be able to edit the document within Word.
«1

Comments

  • nelsonnelson Member Posts: 107
    Hi,

    Have you tried saving the Document Reports from Navision as HTML and then opening them with Word?

    It's the most simple way and it could prove useful enough.
    Nelson Alberto
  • hdhd Member Posts: 7
    Thanks Nelson, I thought of this as well, but my client would like a .doc file not an HTML file... Any thoughts??
  • astarothastaroth Member Posts: 7
    hd wrote:
    Does anyone know if there is a way to print out Sales documents in Microsoft Word from within Navision? I would like the print functionality of Navision to export a document or text file that can be opened in Word. Ideally, I would like to import the document into Microsoft Word and be able to edit the document within Word.

    Hello,

    You could use Automation to create a Word document, but this requires a little work.

    /Astaroth
  • SavatageSavatage Member Posts: 7,142
    just curious what they would like to edit? maybe there is better way than word depending on what is actually being changed.
  • hdhd Member Posts: 7
    They would like to add some additional text, probably comments etc.. They would also like to store these sales orders that they export outside of Navision (i.e. in .doc format). I have been looking at codeunit 5054 but I don't think that the automation server will work for me...Any thoughts?
  • SavatageSavatage Member Posts: 7,142
    i'm not too familiar with exporting orders into word.

    All our exporting is into PDF's.

    We use pdf995 when we want to print a sales order/invoice/PO/etc.

    It creates a perfect PDF that can be edited by adobe acrobat if necessary.

    PDF's are great for us - i mean who doesn't have the free acrobat reader & pdf995 is free too. Just a few bucks if you want to kill the ad's.

    We use PDF's also because we don't want anyone else to modify a bill.

    We also use the pdf995edit which has a nice feature that once something is printed using pdf995 it automatically opens my email and makes it an attachment. all I have to do is type who it's going to.

    I know it's not fully automatic this method, but it's a start for us and it's been working well.
  • SavatageSavatage Member Posts: 7,142
  • ajayjainajayjain Member Posts: 119
    if you need the code to write word file from navision
    let me know.
    Ajay Jain
    UK
  • hdhd Member Posts: 7
    Ajay,
    If you have some sample code, that would be great. You can either post it here or email it to me at harkd@opendoor.ca

    Thanks,
    Hark Dhunay
  • dezarnaudezarnau Member Posts: 10
    Hello,

    I have a customer who wants the same thing than Hd.

    So if Ajayjain or Hd can email me the code, it would be great. You can post it to cdezarnaulds@apogea.net

    Thanks,

    Cyril.
  • Christian_BuehlChristian_Buehl Member Posts: 145
    Try it this way. I hope that solves most of your all problems.
    Variables used
    Name	    DataType	   Subtype	
    wrdApp	   Automation	 Automation Server.Application	
    wrdDoc	   Automation	 Automation Server.Document	
    wrdRange    Automation	Automation Server.Range	
    wdGotoBookmark	Integer		
    what	 Integer		
    which	Integer		
    count	Integer		
    TemplateName   Text    200
    
    Automation Server is {00020905-0000-0000-C000-000000000046} 8.1
    or the  "Microsoft Word 10.0 Object Library"  
    (depending on Version of Word used,  I prefer using older versions due to compatibilty)
    
    TemplateName := '\\Servername\Name_of_share\folder\wordTemplate.dot';
    CREATE(wrdApp);
    wrdApp.Visible := TRUE;
    IF NOT EXISTS(TemplateName) THEN ERROR (ErrMsgFileNotFound, TemplateName);
    wrdDoc := wrdApp.Documents.Add(TemplateName);
    wrdApp.ActiveDocument.Fields.Update;
    // With Fields in Word
    wrdRange := wrdApp.ActiveDocument.Fields.Item(1).Result;
    wrdRange.Text := YourText;
    
    // Alternatively print at a Bookmark position
    wdGotoBookmark := -1;
    what := wdGotoBookmark;
    tab[1] := 9;
    // which := 1;  // Standard for WdGotoFirst
    // count := 1;  // Standardvalue
    wrdRange := wrdDoc.GoTo(what,which,count,textmarke);
    wrdRange.InsertAfter('your Text');
    wrdRange.InsertAfter(tab);
    wrdRange.InsertAfter('Another Text');
    wrdRange.InsertParagraphAfter;
    // wrdDoc.PrintOut                      //  Print Document to Std. printer
    // wrdDoc.PrintPreview;               // Show Print preview
    wrdApp.Activate;
    clear(wrdApp);
    
  • Edu@rdoEdu@rdo Member Posts: 3
    Hello,

    Can anyone tell me if its possible to delete a row of a table writing code in Navision. I'm exporting a report to a word document and i have to choose one of three options.

    When i choose one of them i want to delete a row in a table.

    Regards
  • ArhontisArhontis Member Posts: 667
    Hi,

    You could try something like:
    WordAF.ActiveDocument.Tables.Item(1).Rows.Item(2).delete;
    
    which deletes the second line of the first table in your word document.
  • Mindi@iigMindi@iig Member Posts: 6
    I currently have a report that needed to be broken down into 3 reports because of a limitation of size. Each report calls the next.

    This allows us to run the report without an error message but it means that there are 2 unwanted pages breaks and page numbers can't be added. It also means that it is difficult to turn the whole thing into one PDF file.

    Would using this method to send the information to Work allow us to have all of the information in one document so that these problems could be corrected?
  • BT_MarcBT_Marc Member Posts: 30
    I use the first way with an .dot file with Fields in Word but i have a problem.
    Writing into thes files works but if i go to print it the fields will be overritten by the standardtext. Can some body help me ?
  • kirankumarkirankumar Member Posts: 29
    Hi

    I have tried the Code that Christian Had Given But at the Compilation it is
    throwing an error like:'The Variable WRDAPP::MAILMERGEDATASOURCEVARIABLE is defined more than once.'

    Could U please Resolve this and give me the Solution.
    Hi
  • cnicolacnicola Member Posts: 181
    Hi guys,

    Matriks Doc does all this stuff out of the box: www.matriks.com .

    They allow saving documents in Navision and attach them to various master records and/or documents (if documents I think they get copied to the posted documents as well).
    You can define Office templates so when you create from Navision from a Customer say a Word document then it will drop all the fields you put in the template such as say Customer Contact Name and address.
    I know it is cool to try doing it yourself but this is a pretty cheap software.
    Apathy is on the rise but nobody seems to care.
  • ajhvdbajhvdb Member Posts: 672
    With 5.0 it is possible too. We implemented Matriks for some customers.

    Because customers wanted headers and lines together in Word we extended Matriks with subtables....

    After this we created ReportX. See my signature for more information.
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    kirankumar wrote:
    Hi

    I have tried the Code that Christian Had Given But at the Compilation it is
    throwing an error like:'The Variable WRDAPP::MAILMERGEDATASOURCEVARIABLE is defined more than once.'

    Could U please Resolve this and give me the Solution.
    Try shorten your automation variable (for example: use a one-character variablename W).
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • ajhvdbajhvdb Member Posts: 672
    Try shorten your automation variable (for example: use a one-character variablename W).

    Didn't you give this advice recently somewhere else? :wink:
  • kirankumarkirankumar Member Posts: 29
    Could any one please provide MSP accesscode to download matriks doc3

    Regards
    Kiran.
    Hi
  • cnicolacnicola Member Posts: 181
    Kiran,

    You know advice is free but software costs. :D
    Matriks Doc is a software for sale so if you want it then you need to contact their sales department and buy it.
    Apathy is on the rise but nobody seems to care.
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    ajhvdb wrote:
    Try shorten your automation variable (for example: use a one-character variablename W).

    Didn't you give this advice recently somewhere else? :wink:
    Indeed. If it works for one, it will probably work for the other too ;-)
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • kirankumarkirankumar Member Posts: 29
    Dear Luc van Dyck,

    But Unfortunately it did't work for this case.

    If any other way to do Compilation with out getting the error
    'The Variable W::MAILMERGEDATASOUREVALIDATE is defined more than once.'

    Try to help out
    Hi
  • SavatageSavatage Member Posts: 7,142
    perhaps you have it defined in Globals and somewhere else in Locals?
  • mnamna Member Posts: 4
    Hi Kirankumar

    Don't know if you have solved the issue, but if you declare the automation server as a locale variable instead of a globale then you wouldn't get the error.

    The problem is, that if you define it as a Global variable then you have det possibility of using the Events on the Automation and since Navision only has 30 characters to define a variable then NAV truncates the rest of the Event Name and thereby creating 2 identical variables. If you create the Automation as a local variabel where it is not possible to use the events then the problem doesn't occur.

    PS. It doesn't help to Set the property WithEvents to No.
  • AngeloAngelo Member Posts: 180
    is there sample codes to show data in microsoft word from navision same as data in list form? I delve into navision's pdf that only 1 record export to microsoft word using automation. How to export it more than 1 record and show it look like list form?

    rgrds,
    Angelo
  • SavatageSavatage Member Posts: 7,142
    Word tip & workaround. For something like getting Nav data into word, like a list form quickly without building something.

    Go to your list & show the columns you want hide the rest.
    Filter on the data, if you want.
    Select All->Copy

    Open Word->paste.
    Select All->Table->Convert->Text to Table.

    The seperator should be TAB.
    probably not necessary in 5, by what I read here & there getting info into MSOffice seems to be pretty easy.
  • DriesDries Member Posts: 29
    Hi,


    This can be created very simple just by using the same code as in he wordmanagement codeunit.

    If you like me to create it for you just show me the type of the doc file of how it will look like and the tables that from which you need to export the data to the word document. \:D/

    Cheers,
    Dries.
  • robertadirobertadi Member Posts: 8
    I store more word documents in blob fields on each item in item table.
    I can open this word doc's from within navision, but i need to export more word docs from within different items into one big word document, automaticaly.
    I also have to insert between this documents a line with information from navision. ](*,)
    Can this be done using word automation?
    Can anyone give me an example?

    Code I use to show one word document at a time :) :
    useFIleName:=STRSUBSTNO(txt00,FORMAT("No.")+'.doc');
    CALCFIELDS(TemplateWord);
    TemplateWord.EXPORT(useFIleName,FALSE);
    
    CREATE(wrdApp);
    
    wrdDoc:=wrdApp.Documents.Add(useFIleName);
    wrdApp.PutFocusInMailHeader();
    
    wrdApp.Visible:=TRUE;
    
Sign In or Register to comment.