Jump to content

Document creation problem


Rex
 Share

Recommended Posts

Hi

For 1 mdr. i have tryed to finde a way to use AutoIT to create a document like the att. one.

I have tryed the word replace function but recives thise errors ;)

--> Word.au3 Error from function _WordDocOpen, $_WordStatus_InvalidObjectType
--> Word.au3 Error from function _WordDocGetCollection, $_WordStatus_InvalidObjectType
--> Word.au3 Error from function _WordDocFindReplace, $_WordStatus_InvalidDataType
--> Word.au3 Error from function _WordQuit, $_WordStatus_InvalidObjectType

Then i thinked of creating a .html and the write it with my info when needed, but i needed it to be printed and file print didn't work got some script error from printer (but it works with plain txt files)

The Doc i am trying to create/print is a Freight Letter, filed with info collected from a booking program I'm creating - but i cant get past the doc creation/printing thing - i realy realy don't know how to do it :evil: .

The info i collected from up to 31 /5 strings containing:

Customer (no limit to chars), Number of Collies(no limit to chars, but rarely over 4 chars, and only Numbers), Collie Type (PLL or CLL)(Limit to 3 chars), Collie Weight (no limit to chars, but rarely over 4 chars, and only Numbers) and last our Order Numbers (Contains 6 digs, and if more then one spitted by a "-", 123456-654321, and no limit to how many order numbers could be entered, as it is our proof that the receiver has received all we send).

Do any of U have an :evil: for me for how to create this?

Cheers

/Rex

Link to comment
Share on other sites

Would you kindly post what you have for code thus far so we can see where you might be going awry?

(And so if someone is so kind enough to assist you, we can potentially avoid completely reinventing the wheel.)

Edited by exodius
Link to comment
Share on other sites

Would you kindly post what you have for code thus far so we can see where you might be going awry?

(And so if someone is so kind enough to assist you, we can potentially avoid completely reinventing the wheel.)

Problem is i don't have any code, well at least not for the doc/print part ;) , course the word thing didn't work gave those errors things, and i dropped the html code after print problem, so i'm back to scratch again (this has been for a month now, thats why i posted here as a last result).

Cheers

/Rex

Link to comment
Share on other sites

Try this from the same directory as your Word Document is in:

#include <Word.au3>
$oWord = _WordCreate(@ScriptDir & "\test.doc")
$oWordDoc = _WordDocGetCollection($oWord, 0)
_WordDocFindReplace($oWordDoc, "SENDER NAME", "Santa Claus")
_WordDocPrint($oWordDoc)

Tryed, and failed ;)

--> Word.au3 Error from function _WordDocOpen, $_WordStatus_InvalidObjectType
--> Word.au3 Error from function _WordDocGetCollection, $_WordStatus_InvalidObjectType
--> Word.au3 Error from function _WordDocFindReplace, $_WordStatus_InvalidDataType
--> Word.au3 Error from function _WordDocPrint, $_WordStatus_InvalidDataType
+>01:25:02 AutoIT3.exe ended.rc:0

Could it be becorse i'm useing O2k7 ?

Cheers

/Rex

EDIT: O2K7

Edited by Rex
Link to comment
Share on other sites

I'm also using Office 2007 and it works for me, so that can't be it.

Now you did modify my code to point to the name of your .doc file right?

Yes i did change the path and name of *.doc file.

I'm using AutoIT 3.3.2.0

Word opens, but nothing happens ;) other then the error from SciTE Console, the same prob i have had every time i tryed, that's why i wanned to try something other also this way making sure that the prog can be used on pc's without Office.

Cheers

/Rex

EDIT: AutoIT Updated

Edited by Rex
Link to comment
Share on other sites

Well i have now created a htm file using word, and then used tons of hours on cleaning out word style html thing :evil:

My htm code looks like this.

<html>

<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
</head>

<body lang=DA>

<div class=Section1>

<table border=0 cellpadding=0 style="border-collapse: collapse">
 <tr>
  <td width=217 colspan=3 valign=top>
  <p><img border="0" src="Logo.png" width="162" height="82"></p>
  </td>
  <td width=253 colspan=10 valign=top>
  <p>&nbsp;</p>
  </td>
  <td width=182 colspan=2 valign=bottom>
  <p><font size="2"><b><span style="font-family: Arial">COMPANY</span></b></font><span style='font-family:Arial'><font size="2"><b>
  A/S</b><br>
    Address<br>
    ZIP </font></span><font size="2"><span style="font-family: Arial">CITY</span></font></p>
  </td>
 </tr>
 <tr>
  <td width=470 colspan=13 valign=top>
  <p><span style='font-family:"Arial Black"'><font size="6">F
  R A G T B R E V</font></span></p>
  </td>
  <td width=73 valign=top>
  <p><span><font size="2" face="Arial">CVR DK</font></span></p>
    <p>
    <span><font size="2" face="Arial">Tel.</font></span></p>
  </td>
  <td width=109 valign=top>
  <p>
    <span><font size="2" face="Arial">1</font></span><font face="Arial" size="2">23456789</font></p>
  <p><span><font size="2" face="Arial">+45 00 00 00 00 +45 00 00 00 00</font></span></p>
  </td>
 </tr>
 <tr>
  <td width=235 colspan=5 valign=bottom>
  <p>Modtager:</p>
  </td>
  <td width=235 colspan=8 valign=bottom>
  <p>Afsender:</p>
  </td>
  <td width=73 valign=top>
  <p>
    <span><font face="Arial" size="2"><br>
    Fax+</font></span></p>
  </td>
  <td width=109 valign=top>
  <p>
    <span>
    <font face="Arial" size="2"><br>
    +45 00 00 00 00<br>
    +45 00 00 00 00<br>
    &nbsp;</font></span></p>
  </td>
 </tr>
 <tr>
  <td width=235 colspan=5 valign=bottom>
  <p><b><span style='font-size:14.0pt'>COMPANY
  NAME</span></b></p>
  </td>
  <td width=235 colspan=8 valign=bottom>
  <p><i>SENDER NAME</i></p>
  </td>
  <td width=73 valign=top>
    <font face="Arial" size="2">
    <span>E-mail</span></font></td>
  <td width=109 valign=top>
    <span>
    <font face="Arial" size="2">E@mail.dk</font></span></td>
 </tr>
 <tr>
  <td width=235 colspan=5>
  <p><span>&nbsp;</span></p>
  </td>
  <td width=235 colspan=8>
  <p><i><span>&nbsp;</span></i></p>
  </td>
  <td width=182 colspan=2 valign=top>
  <p><font face="Arial" size="2"><span>www.COMPANY.dk</span></font></p>
  </td>
 </tr>
 <tr>
  <td width=235 colspan=5>
  <p><b>ADDRESS</b></p>
  </td>
  <td width=235 colspan=8>
  <p><i>SENDER ADDRESS1</i></p>
  </td>
  <td width=182 colspan=2 valign=top>
  <p class=MsoNormal><span>&nbsp;</span></p>
  </td>
 </tr>
 <tr>
  <td width=235 colspan=5>
  <p><b>ADDRESS2</b></p>
  </td>
  <td width=235 colspan=8>
  <p><i>SENDER ADDRESS2</i></p>
  </td>
  <td width=182 colspan=2 valign=top>
  <p><span>&nbsp;</span></p>
  </td>
 </tr>
 <tr>
  <td width=64>
  <p><b>ZIP</b></p>
  </td>
  <td width=171 colspan=4>
  <p><b>CITY</b></p>
  </td>
  <td width=50 colspan=3>
  <p><i>SZIP</i></p>
  </td>
  <td width=185 colspan=5>
  <p><i>SENDER CITY</i></p>
  </td>
  <td width=182 colspan=2>
  <p><span>DATE</span></p>
  </td>
 </tr>
 <tr>
  <td width=652 colspan=15 valign=top>
  <p><span>&nbsp;</span></p>
  </td>
 </tr>
 <tr>
  <td width=130 colspan=2 valign=top>
  <p>Ordre Nummer<span></span></p>
  </td>
  <td width=522 colspan=13 valign=top>
  <p ><u><span>ORDRENR</span></u></p>
  </td>
 </tr>
 <tr>
  <td width=652 colspan=15 valign=top>
  <p><span>&nbsp;</span></p>
  </td>
 </tr>
 <tr>
  <td width=130 colspan=2 valign=top >
  <p>Modtager Dato:</p>
  </td>
  <td width=130 colspan=4 valign=top>
  <p><span></span></p>
  </td>
  <td width=115 colspan=5 valign=top>
  <p><span >Lev. inden kl.:</span></p>
  </td>
  <td width=276 colspan=4 valign=top>
  <p><span>TIME</span></p>
  </td>
 </tr>
 <tr>
  <td width=130 colspan=2 valign=top>
  <p>Bemærkning<span>:</span></p>
  </td>
  <td width=522 colspan=13 valign=top>
  <p><span>COMMENT</span></p>
  </td>
 </tr>
 <tr>
  <td width=652 colspan=15 valign=top>
  <p><span>&nbsp;</span></p>
  </td>
 </tr>
 <tr>
  <td width=652 colspan=15 valign=top>
  <p><span>&nbsp;</span></p>
  </td>
 </tr>
 <tr>
  <td width=225 colspan=4 valign=top>
  <p><u>Kunde.</u></p>
  </td>
  <td width=38 colspan=3 valign=top>
  <p><u>Cl</u></p>
  </td>
  <td width=47 colspan=2 valign=top>
  <p><u>Art</u></p>
  </td>
  <td width=66 colspan=2 valign=top>
  <p><u><span>Vægt</span></u></p>
  </td>
  <td width=276 colspan=4 valign=top>
  <p><u>Ordre
  Nr.<span></span></u></p>
  </td>
 </tr>
 <tr style='height:400pt'>
  <td width=225 colspan=4 valign=top>
  <p><span><font size="2">&nbsp;</font></span></p>
  </td>
  <td width=38 colspan=3 valign=top>
  <p><span><font size="2">&nbsp;</font></span></p>
  </td>
  <td width=47 colspan=2 valign=top>
  <p>&nbsp;</p>
  </td>
  <td width=66 colspan=2 valign=top>
  <p>&nbsp;</p>
  </td>
  <td width=276 colspan=4 valign=top>
  <p'></p>
  </td>
 </tr>
 <tr>
  <td width=262 colspan=7 valign=top style="border-top: 3px solid #000000">
  <p align="center"><font face="Arial">Kvittering Chauffør</font></p>
  </td>
  <td width=64 colspan=3 valign=top>
  <p><font face="Arial"><span>&nbsp;</span></font></p>
  </td>
  <td width=69 colspan=2 valign=top>
  <p><font face="Arial"><span>&nbsp;</span></font></p>
  </td>
  <td width=257 colspan=3 valign=top style="border-top: 3px solid #000000">
  <p align="center"><font face="Arial"><span>Kvittering for modtagelse.</span></font></p>
  </td>
 </tr>
 <tr height=0>
  <td width=64 style='border:none' height="3"></td>
  <td width=66 style='border:none' height="3"></td>
  <td width=87 style='border:none' height="3"></td>
  <td width=7 style='border:none' height="3"></td>
  <td width=10 style='border:none' height="3"></td>
  <td width=26 style='border:none' height="3"></td>
  <td width=2 style='border:none' height="3"></td>
  <td width=23 style='border:none' height="3"></td>
  <td width=25 style='border:none' height="3"></td>
  <td width=17 style='border:none' height="3"></td>
  <td width=50 style='border:none' height="3"></td>
  <td width=19 style='border:none' height="3"></td>
  <td width=75 style='border:none' height="3"></td>
  <td width=73 style='border:none' height="3"></td>
  <td width=109 style='border:none' height="3"></td>
 </tr>
 </table>

</div>

</body>

</html>

Then i think that all i need is to do som filewrite writing until i have included the entire html doc in my script, then i think/hope that i can do some inserting where i want my info :evil: .

How ever I'm not a web gui thing, and not shure on how to make shure that the htm file can be printen on one page without top/buttom info text from browser.

And still i havn't found a way to open/print with Auto IT ;)

Really hope that some of U can help me with this problem.

Cheers

/Rex

Link to comment
Share on other sites

Hi

Just to wrap this up.

I ended up using search and replace to change the needed info in my html, then i call a html2pdf build in pyton (couldn't find a way to do this with AutoIT :evil: ) to create a pdf file from my html to ensure identical print result every time ;)

Cheers

/Rex

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...