PageSendToPowerPointΒΆ

PageSendToPowerPoint creates a PowerPoint document from the given pages. This function uses the COM interface. PowerPoint must be installed.

bool = PageSendToPowerPoint(hvPage, ssTemplate, ssSaveName, bAppend, bClose)

Return Value

bool TRUE (1) if the file is created successfully; otherwise FALSE (0).

Parameters

hvPage

Vector with page handles.

ssTemplate

ssTemplate is the name of a PowerPoint template file. See File=>Send to PowerPoint. If an empty string is used, not template will be used.

ssSaveName

Is the name for the PowerPoint file.

bAppend

If TRUE (1) and a PowerPoint file with the Name ssSaveName already exists, the given pages will be added to the PowerPoint document. Otherwise the PowerPoint file will be replaced.

bClose

If bClose is TRUE (1), the open PowerPoint document will be closed.

Example

// Select UniPlot document and export to PowerPoint
RegisterCommand("File", "MyPPExport", "Export IPW/IPZ to Powerpoint");
UserBar_Add("MyPPExport");

def MyPPExport()
{
    ssFilter = _s("UniPlot Files (*.ipw;*.ipz) |*.ipw;*.ipz|All (*.*)  |*.*|");
    svFile = GetOpenFileName("", ssFilter, 1, 1);
    if (svFile[1] == "") {
        return;
    }

    ssTemplate = "";
    ssUseTemplate = GetProfileString("settings", "PowerPointTemplate_use");
    if (ssUseTemplate == "1") {
        ssTemplate = GetProfileString("settings", "PowerPointTemplate");
        ssTemplate = MakeFullPath(ssTemplate);
    }
    bAppend = FALSE;
    bClose = TRUE;
    bBoundingBox = (GetProfileInt("settings", "PowerPoint_UseBoundingBox", "", 1) == 1);


    nFiles = len(svFile);
    for (iFile in 1:nFiles) {
        hDoc = _DocIsOpen(svFile[iFile]);
        if (hDoc != 0) {
            log_warning("", "Ignore open file", "Please close all IPW/IPZ files");
            // ignore open files
            continue;
        }

        hDoc = DocCreate(svFile[iFile]);
        if (hDoc == 0) {
            log_error("", svFile[iFile], "Cannot open file");
            continue;
        }
        hvPage = DocGetAllPages(hDoc);

        for (i in 1:len(hvPage)) {
            if (PageGetAttrib(hvPage[i]) == 1) {
                // remove pages with do not print attribute
                hvPage[i] = 0;
            }
        }
        hvPage = remove(hvPage);

        svPath = SplitPath(svFile[iFile]);
        ssSaveName = sum(svPath[1:3]) + ".pptx";

        PageSendToPowerPoint(hvPage, ssTemplate, ssSaveName, bAppend, bClose, bBoundingBox);
        DocDestroy(hDoc);
    }
}

id-551