Write to word not using automation

PolarPolar Member Posts: 32
edited 2006-02-01 in NAV Tips & Tricks
You can write to Word not using automation.
1. Navision can write to file
2. You can use HTML
3. Word can open HTML files

Example
FileMyHTML	File		
OutStream1	OutStream	
Customer                  Record       Customer 

function wr(t : Text[250])
OutStream1.WRITETEXT(t);


FileMyHTML.CREATE('C:\main.doc');
FileMyHTML.TEXTMODE(TRUE);
FileMyHTML.CREATEOUTSTREAM(OutStream1);



wr('<HTML><HEAD> ');
wr('<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=cp866"> ');
// cp866 means DOS encoding , I had problem with cirillic 
wr('<META NAME="Generator" CONTENT="Microsoft Word 97"> ');
wr('<TITLE>File Title </TITLE> ');
wr('</HEAD><BODY> ');
wr('<B><FONT FACE="Times New Roman" SIZE=4> ');
wr('<P ALIGN="CENTER">Customers '+FORMAT(rec."No.")+' </P> ');
wr('</B></FONT> ');



wr('<OL> ');
IF Customer.FIND('-') THEN
    REPEAT 
    wr(' <LI>'+ FORMAT(Customer.Name)+'</LI>');
    UNTIL CUSTOMER.NEXT = 0 
wr('</OL> </BODY></HTML>');


FileMyHTML.CLOSE();
HYPERLINK('C:\main.doc');

You can make a template CU with HTML header and footer and use it for making reports to word or beautiful invitation cards on your presentations
Using HTML you may not care of version of microsoft office.
Reports are much faster than if you use automation
And you will have more degrees of freedom
:D
keep it simple

Comments

  • KABOUTERKABOUTER Member Posts: 30
    How can I use your code sample to put something in the Word Header and Word Footer Section, example a picture logo and page number?
Sign In or Register to comment.