guland 发表于 2010-10-15 08:17:14

谁能给个调用word模板打印的例子

如题,最近正在为自己的店铺编一个简单的进销存软件,但是现在被打印这块给难住了,谁能教教我怎么才能调用word模板打印


谢谢啦!{:face (319):}

3mile 发表于 2010-10-15 09:34:50

没有打印机。
在官网找了个UDF,你去看看http://www.autoitscript.com/forum/index.php?showtopic=120667&st=0&p=838932&hl=print&fromsearch=1&#entry838932

3mile 发表于 2010-10-15 10:03:05

在UDF中仔细找了下,的确有针对WORD的打印函数。
#include <Word.au3>
_WordDocPrint ( ByRef $o_object [, $b_Background = 0 [, $i_Copies = 1 [, $i_Orientation = -1 [, $b_Collate = 1 [, $s_Printer = "" [, $i_Range = 0 [, $i_From = "" [, $i_To = "" [, $s_Pages = "" [, $i_PageType = 0 [, $i_Item = 0]]]]]]]]]]] )

UDF中例子如下:
; *******************************************************
; Example 1 - Create a word window, open a document, set the text,
;                                print with defaults, and quit without saving changes.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc")
$oDoc = _WordDocGetCollection ($oWordApp, 0)
$oDoc.Range.Text = "This is some text to print."
_WordDocPrint ($oDoc)
_WordQuit ($oWordApp, 0)

; *******************************************************
; Example 2 - Create a word window, open a document, set the text,
;                                print using landscape, and quit without saving changes.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc")
$oDoc = _WordDocGetCollection ($oWordApp, 0)
$oDoc.Range.Text = "This is some text to print."
_WordDocPrint ($oDoc, 0, 1, 1)
_WordQuit ($oWordApp, 0)

; *******************************************************
; Example 3 - Create a word window, open a document, set the text,
;                                print to a printer named "My Printer", and quit without saving changes.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc")
$oDoc = _WordDocGetCollection ($oWordApp, 0)
$oDoc.Range.Text = "This is some text to print."
_WordDocPrint ($oDoc, 0, 1, 0, 1, "My Printer")
_WordQuit ($oWordApp, 0)

xrbenbeba 发表于 2010-10-15 12:14:19

很简单 直接用word录制一个宏 然后调用application类改写成au3的就行了.

king8462 发表于 2010-10-15 14:46:02

很简单 直接用word录制一个宏 然后调用application类改写成au3的就行了.
xrbenbeba 发表于 2010-10-15 12:14 http://www.autoitx.com/images/common/back.gif


楼上给个例子看看

guland 发表于 2010-10-15 21:19:21

回复 3# 3mile


    3Q!我有时间试试看

guland 发表于 2010-10-15 21:53:47

回复 3# 3mile


    刚刚我试了下,我需要的是调用WORD模板,而不是创建WORD再打印,像图片中那样,图片中那个模板是RTF的

3mile 发表于 2010-10-15 22:16:06

回复 7# guland
因为没有打印机,没法给出具体的代码。
不过我想,可不可以用_WinAPI_CreateFile打开设备,使其作打印的动作呢?

guland 发表于 2010-10-15 23:29:48

回复 8# 3mile


    打印时可以实现的,我只是需要打印变量,模板是可以随意修改的

netegg 发表于 2010-10-16 09:13:53

$i_Item 参数设置为3行不行
页: [1]
查看完整版本: 谁能给个调用word模板打印的例子