I would like to know how can i determine, whether a variant is referencing an OLE automation object, or not.
I'm exporting some Excel graphs to Powerpoint.
I have this code:
var PptFile: Variant;
....
// PptFile _might_ be initialized:
PptFile:=pptApp.Presentations.Open(pptFilename);
// It depends on whether the export has items which need to be exported to
// Powerpoint or not
....
// I would like to determine if PptFile does reference an OLE automated object or not
PptFile.SaveAs(excelFileName+'.pptx');
I know, it could be done by placing the last line of the code (with saveAs) between try...except...end
, but i don't feel that approach is good enough.
I was reading about VarIsEmpty
, VarIsEmptyParam
, Nothing, this question, but i'm not sure about this.
You should use
VarIsClear
for this test.However, I question whether or not it is needed. How could it be that
PptFile
was not assigned? That can only happen if the call topptApp.Presentations.Open()
fails, and that would raise an exception. Or am I mis-understanding this? I cannot at the present see any scenario in which you could reach the call toPptFile.SaveAs()
for whichPptFile
had not been assigned.