带有可选参数的 powershell 调用方法 [英] powershell Call method with optional arguments
本文介绍了带有可选参数的 powershell 调用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 excel vba 代码,可以在工作表中找到特定的单元格.它使用 Excel 库中的 Find
方法.这是代码
I have an excel vba code that finds a particular cell in a sheet. It uses the Find
method form the excel libraries. Here is the code
objRange.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows)
我需要在 powershell 中做同样的事情.但是这个方法总共有 9 个参数.如何忽略 powershell 中的其他可选参数.像这样吗?
I need to do the same thing in powershell. But this method has a total of 9 arguments. How to ignore the other optional arguments in powershell. Something like this?
$range.Find("*", "", "", "", $xlByRows, $xlPrevious, "", "", "")
这里是Range.Find
方法的文档
推荐答案
$null
不起作用,但根据 这个答案 你可以使用 [Type]::Missing
:
$null
doesn't work, but according to this answer you can use [Type]::Missing
:
$default = [Type]::Missing
$xl.Cells.Find("*", $default, $default, $default, $xlByRows, $xlPrevious,
$default, $default, $default)
这篇关于带有可选参数的 powershell 调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文