我希望将文件保存为使用用户在开头输入的变量STYLE。
我还需要帮助将数据发送到具有可变份数的打印机。
从这里开始,我需要帮助:
ComObjActive("Word.Application").ActiveDocument.SaveAs("L:\10. 2016\TKT Issued\"%Style%")
请查看以下代码,了解我已有的内容。
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
F12::
Gui, Add, Text,, Please enter Style:
Gui, Add, Edit, vStyle
Gui, Add, Text,, Please enter Price:
Gui, Add, Edit, vPrice
Gui, Add, Text,, Please enter Docket Number:
Gui, Add, Edit, vDocket
Gui, Add, Text,, Please enter Page Quantity:
Gui, Add, Edit, vPages
Gui, Add, Button, default, OK
Gui, Show,, Cutting Ticket Producer
return
GuiClose:
ButtonOK:
Gui, Submit
MsgBox You entered Style: %Style%, Price: %Price%, Docket Number: %Docket% and%Pages% Pages. Data will be sent to printer.
MSWordMultiReplace("STYLE",Style, "PRICE", Price, "DKT", Docket)
MSWordMultiReplace(params*) { ; by Learning one
oWord := ComObjCreate("Word.Application")
a:="L:\10. 2016\TKT Issued\TEMPLATE.doc"
oWord.Documents.Open(a)
oWord.Selection.Find.ClearFormatting
oWord.Selection.Find.Replacement.ClearFormatting
For k,v in Params
{
c++
if (c = 1)
{
st := v
continue
}
rt := v, c := 0
oWord.Selection.Find.Execute(st, 0, 0, 0, 0, 0, 1, 1, 0, rt, 2)
}
ComObjActive("Word.Application").ActiveDocument.SaveAs("L:\10. 2016\TKT Issued\"%Style%")
ExitApp
}
Reload
答案 0 :(得分:0)
尝试:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
F12::
Gui, Add, Text,, Please enter Style:
Gui, Add, Edit, vStyle
Gui, Add, Text,, Please enter Price:
Gui, Add, Edit, vPrice
Gui, Add, Text,, Please enter Docket Number:
Gui, Add, Edit, vDocket
Gui, Add, Text,, Please enter Page Quantity:
Gui, Add, Edit, vPages
Gui, Add, Button, default, OK
Gui, Show,, Cutting Ticket Producer
return
GuiClose:
ButtonOK:
Gui, Submit
MsgBox You entered Style: %Style%, Price: %Price%, Docket Number: %Docket% and%Pages% Pages. Data will be sent to printer.
MSWordMultiReplace("STYLE",Style, "PRICE", Price, "DKT", Docket)
MSWordMultiReplace(params*) { ; by Learning one
oWord := ComObjCreate("Word.Application")
a:="L:\10. 2016\TKT Issued\TEMPLATE.doc"
oWord.Documents.Open(a)
oWord.Selection.Find.ClearFormatting
oWord.Selection.Find.Replacement.ClearFormatting
For k,v in Params
{
c++
if (c = 1)
{
st := v
continue
}
if (k == 2)
Style := v
rt := v, c := 0
oWord.Selection.Find.Execute(st, 0, 0, 0, 0, 0, 1, 1, 0, rt, 2)
}
oWord.ActiveDocument.SaveAs("L:\10. 2016\TKT Issued\" Style)
ExitApp
}
Reload
答案 1 :(得分:0)
您无法直接访问Style
变量。你必须把它作为你传递的第二个参数。请参阅以下代码,
For k,v in params
{
if (k = 2)
{
fileloc = L:\10. 2016\TKT Issued\%v%
ComObjActive("Word.Application").ActiveDocument.SaveAs(fileloc)
}
}
这对我有用