Origin Cのアクセスパワーポイント

原点C PowerPointのアクセスポイントと6つの主要ステップ:

1. PowerPointアプリケーションオブジェクトを作成、または現在開いているPowerPointアプリケーションを取得します。

よる起源のC CreateObject関数を作成します。

Object ppt;
// 新建一个PowerPoint应用
try {
    ppt = CreateObject("powerpoint.application");
} catch (int err) {
    printf("新建PowerPoint出错!");
}
if (ppt == NULL) {
    printf("新建PowerPoint出错!");
    return;
}

そしてを通じてオープンPowerPointアプリケーションオブジェクトを取得GetActiveObject達成します。

Object ppt;
// 获取已经打开的PowerPoint应用
try {
    ppt = GetActiveObject("powerpoint.application", false);
} catch(int err) {
    printf("获取打开的PowerPoint出错!");
}
if (ppt == NULL) {
    printf("获取打开的PowerPoint出错!");
    return;
}

2.デモを作成するか、オブジェクトを取得し、PowerPointファイルを開きます。あなたは、PowerPointファイルを開くことができます。また、オープンPowerPointファイルを取得することができます。

パスを指定することにより、PowerPointファイルを開くには。

// 打开一个PowerPoint文件
Object presentation;
// PowerPoint文件的全路径
string strTemplate = GetOriginPath(ORIGIN_PATH_SYSTEM) + "Samples\\Import and Export\\Column_Plots_in_Sample_OPJ.pptx";
presentation = ppt.Presentations.Open(strTemplate);
if (presentation == NULL) {
    printf("打开文件失败!");
    return;
}

また、既に開いているPowerPointファイルを拾うことができます。

Object presentation;
int numPres = ppt.Presentations.Count;  // 当前PowerPoint应用打开的所有演示文件
if (numPres < 1) {  // 如果没有文件打开,新加一个
    presentation = ppt.Presentations.Add(1);  // 新加一个文件
} else {
    presentation = ppt.Presentations(numPres);  // 拿到最后一个打开的文件
}
if (presentation == NULL) {
    printf("打开演示文件失败!");
    return;
}

3.増加またはPowerPointファイルをスライドさせます。

int numSlide = presentation.Slides.Count;  // 一共有多少张幻灯片
Object slide;
if (numSlide < 1) {  // 如果一张幻灯片都还没有,就新加一张
    slide = presentation.Slides.Add(1, 12);  // ppLayoutBlank == 12, 新增一张空幻灯片
} else {
    slide = presentation.Slides(numSlide-1);  // 倒数第二张幻灯片
}
// 插入一张幻灯片,用前一张作为模板
Object slide2;
slide2 = slide.Duplicate();

4.スライドは、オブジェクトを操作するために使用することができます。

ここでパワーポイントの図でのコピー&ペースト起源です。

string strGraphPageName = "Graph1";  // 要保证有Graph1这个图
GraphPage gp(strGraphPageName);
if (!gp) {
    printf("粘贴失败!");
    return;
}
gp.LT_execute("Clipboard %H");  // 复制Origin的图到剪贴板
Object shapes;
shapes = slide.Shapes;
if (shapes == NULL) {
    printf("粘贴失败!");
    return;
}
shapes.PasteSpecial(3);  // ppPasteMetafilePicture == 3,粘贴到PowerPoint

5. PowerPointファイルを保存します。

presentation.SaveAs("D:\\test.pptx");

6. PowerPointを終了します。

ppt.Quit();

原点はまた、ヘッダ含むことができ、組み込みのクラスPowerPointの操作を提供するPowerPoint.h、特定のクラス及びメソッドを直接開いているファイルのヘッダを参照することができます。

#include <..\originlab\PowerPoint.h>

:githubのは、ソースコードをダウンロードすることができますhttps://github.com/gkimeeq/OriginAdvancedApplication

おすすめ

転載: www.cnblogs.com/Ooman/p/11089275.html
おすすめ