I am using the following powershell code to search through a excel document for a string and return true or false depending on if its found.
if (test-path $filePath) {
$wb = $xl.Workbooks.Open($filePath)
if ([bool]$xl.cells.find("German")) {$found = 1}
}
I want to be able to get the cell reference of the string if its found but I cant figure it out or find an answer on google. Can you help?
While there is a method to search through an entire workbook for a value, typically a Range.Find method is performed on a worksheet. You are setting a var to the workbook but still using the application as the search. You should be getting the worksheet to search from the workbook and using that as the target of the Find operation.
Following are some suggested modifications to your PS1.
To continue the search for all occurrences use the Range.FindNext method until you loop back to the original cell address.
It's hard to provide much more than generalities since so much of your code is missing. I've filled in the missing information with my own test environment.