从PowerPoint API中的CustomLayoutsPtr获取CustomLayoutPtr
Get CustomLayoutPtr from CustomLayoutsPtr in PowerPoint API
我正在尝试加载一个pot文件,并根据需要使用它的布局。
在VBA中,它是这样的:
Sub setLayout()
Call LoadDesign
ActivePresentation.Slides(1).CustomLayout = ActivePresentation.Designs(1).SlideMaster.CustomLayouts(3)
End Sub
Sub LoadDesign()
ActivePresentation.Designs.Load TemplateName:="C:myPptTemplate.pot", Index:=1
End Sub
在C++中,我尝试过:
PowerPoint::DesignPtr my_design= my_active_presentation->Designs->Load(as_bstr(template_filename), 1);
PowerPoint::CustomLayoutsPtr my_layouts = my_design->SlideMaster->CustomLayouts;
PowerPoint::CustomLayoutPtr my_layout = my_layouts->Item(_variant_t(1));
它在VBA中运行良好,但在C++中则不然。我无法从my_layouts获取CustomLayoutPtr。它抛出一个异常E_INVALIDARG。
如果你能告诉我如何解决这个问题,我将不胜感激。
参考:
MSO API 2007
VS2008
解决方案是使用:
long i=1;
_variant_t index(i, VT_I4);
VT_I4 4 4字节带符号整数。
在32位系统上,VT_INT是一个32位有符号整数。
在64位系统上,VT_INT是一个64位有符号整数。
我有一个64位,但VT_INT仍然不起作用。也许是一些内部问题。
希望它能有所帮助。
相关文章:
- C++为构建时间获取QDateTime的可靠方法
- lambda参数转换为constexpr技巧,然后获取带链接的数组
- 如何使用 < 和 > 命令获取 c++ 中的输入和输出?
- 使用指针从C++中的数组中获取最大值
- 如何获取std::result_of函数的返回类型
- 如何在openssl-ecc中获取十六进制格式的私钥
- 使用Unreal C++获取VR耳机的世界位置/方向
- 获取日期异步信号安全吗?如果在信号处理程序中使用,它会导致死锁吗
- 从C字符串中获取奇怪的字符串长度
- 为什么我的for循环不能正确获取argv
- 从python中调用C++函数并获取返回值
- 如何获取一个数字的前3位
- 获取字符串的长度并将其分配给数组
- 无法获取菜单选择以运行函数.C++
- 数组长度,为什么从命令行获取时不能使用它?
- Boost Spirit,获取迭代器内部语义动作
- 尝试通过OCI例程从Oracle获取blob数据,但出现错误:ORA-01008:并非所有变量都绑定
- 具有默认值的引用获取函数
- xmake总是报告:错误:无法获取cxx的程序,为什么
- 在c++中获取大文件的大小