I am trying to load a pot file and use its layouts depending on the requirements.
In VBA it is something like this:
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
In C++, I tried:
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));
It is working fine in VBA, but not in C++. I cannot get a CustomLayoutPtr from my_layouts. It throws an exception E_INVALIDARG.
I would be thankful if you share any ideas about how can I fix this issue.
Ref:
MSO API 2007
VS2008
The solution is to use:
long i=1;
_variant_t index(i, VT_I4);
VT_I4 4-byte signed integer.
On a 32-bit system, VT_INT is a 32-bit signed integer.
On a 64-bit system, VT_INT is a 64-bit signed integer.
I am having a 64-bits, but still VT_INT didn't work. Maybe some internal issues.
Hope it will help.