[英]OleProcedure() C++ Builder 10.3
I try to select 10 characters in Word document with C++ Builder. 我尝试使用C ++ Builder在Word文档中选择10个字符。
VBA method looks as follows: VBA方法如下所示:
Selection.SetRange Start:=0, End:=10
How to correctly pass parameters to C++ Builder method? 如何正确地将参数传递给C ++ Builder方法?
I tried several options, but did not succeed. 我尝试了几种选择,但没有成功。
selection.OleProcedure("SetRange", Start:=0, End:=10)
selection.OleProcedure("SetRange", "Start:=0", "End:=10")
selection.OleProcedure("SetRange", 0, 10)
OleProcedure()
does not support named parameters 1 . OleProcedure()
不支持命名参数 1 。 You have to pass the parameter values in the same order that they are declared by the COM object, which in this case is: 您必须以与COM对象声明的顺序相同的顺序传递参数值,在这种情况下为:
expression.SetRange(Start, End)
So selection.OleProcedure("SetRange", 0, 10)
should work just fine. 因此, selection.OleProcedure("SetRange", 0, 10)
应该可以正常工作。 If it is not, you need to be more specific about what exactly is not working for you. 如果不是,那么您需要更具体地确定到底什么对您不起作用。
1: if you want to use named parameters, you will have to access the variant's held IDispatch
interface and call its IDispatch::Invoke()
method directly, providing it with a DISPPARAMS
struct containing the desired names and values. 1:如果要使用命名参数,则必须访问该变量的保留IDispatch
接口并直接调用其IDispatch::Invoke()
方法,并为其提供包含所需名称和值的DISPPARAMS
结构。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.