如何在vc ++中将形状转换为嵌入式形状 [英] How to convert shape to Inline shape in vc++
本文介绍了如何在vc ++中将形状转换为嵌入式形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好C ++专家!
我需要将MS Word形状对象转换为嵌入式形状.
我正在尝试将下面的VB代码移植到C ++,但出现rCOMError(INVALID ARGUMENT).
Hello C++ Gurus!!
I need to convert the MS Word shape object to Inline shape.
I am trying to port the below VB code to C++ but getting a rCOMError(INVALID ARGUMENT).
Sub ConvertToInlineShape()
With Selection
' \\ If we selected a Shape then convert to InlineShape
If .Type = wdSelectionShape Then
.ShapeRange(1).ConvertToInlineShape
End If
End With
End Sub
我做了以下代码更改:
I have done the following code changes:
MsWord::ShapesPtr shapes = wordDoc->Shapes;
MsWord::ShapePtr shape;
long shapeCount = wordDoc->Shapes->Count;
for(long i = 1; i <= shapeCount; i++)
{
shape = shapes->Item((variant_t *)&i);
if(shape != NULL)
{
inlineShape = shape->ConvertToInlineShape();
}
}
请任何人建议,解决上述问题.
在此先感谢!!!
--- Vieer
Please anyone suggest, the solution of the above problem.
Thanks in Advance!!!
---Vieer
推荐答案
您正在将指向long
的指针转换为variant_t
.这将不起作用(Word将检查变体类型并返回错误).您应该创建一个变量变量并传递此变量:
You are casting a pointer tolong
to avariant_t
. This will not work (Word will check the variant type and return the error). You should create a variant variable and pass this:
// Cast to long and specify type here to let the compiler know which
// of the variant_t constructors is to be used.
variant_t vt((long)i, VT_I4);
shape = shapes->Item(&vt);
Jochen,
非常感谢您的回复,它对我有用...干杯... :)
谢谢,
Vieer
Hi Jochen,
Thanks a ton for your response, it works for me...cheers...:)
Thanks,
Vieer
这篇关于如何在vc ++中将形状转换为嵌入式形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文