I'm trying to adapt the following code (viewtopic.php?f=76&t=101642&sid=1ecd7f2c0ad372a3a1bfb19936fcebe7):
Code: Select all
st := a_tickcount
Clipboard := ""
Send, ^c
Clipwait, 0.2
needle := clipboard, clipboard := ""
if !needle
{
msgbox Clipboard was empty
exitapp
}
filepath := "C:\Users\" A_UserName "\Scripts\test123B.xlsx"
xl := ComObjCreate("excel.application")
xl.DisplayAlerts := False
wrkbk := xl.workbooks.open(filepath)
found := xl.Cells.Find(needle,,,1)
if !found
msgbox % "Nothing found `n" a_tickcount - st
else
{
found.entirerow.cells.copy
msgbox % clipboard "`n" a_tickcount - st
}
wrkbk.close(0)
xl.quit()
return
To create a script that searches for a "Search-Keywords" from an Excel file in a Word file. And if there is a match, outputs the result to an Excel file (or TXT file).
i.e. in the open Word file after the first search term from Excel (first row in the first column, A1), then the second search string (A2) and so on (up to A-n).
If there is a match, then the whole row (A1:B1) of the searched string must be copied from Excel and written to a new Excel (or TXT) file as a result (it can be one match or more).
Would be grateful for any help.
Thanks and regards