我希望文件保存爲使用用戶在開始處輸入的變量STYLE。AHK COM保存時通過文件路徑傳遞變量
我還需要幫助將數據發送到具有可變數量副本的打印機。
從這裏就是我需要幫助:
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
這沒有奏效。 –
由於某種原因,我忽略了可變參數函數,編輯了答案,讓我知道這是否有幫助。 – errorseven
非常感謝您的幫助。你能幫助打印部分嗎? –