VSTO学习总结

 博主承接各类外包,有意请点击查看博主技术栈

相关资料参考

MSDN参考资料:
PowerPoint 2013 开发
http://msdn.microsoft.com/zh-cn/library/office/fp161225.aspx

PowerPoint 2013 开发人员参考 (机器翻译)
http://msdn.microsoft.com/zh-cn/library/office/ee861525.aspx

PowerPoint 2013对象模型引用
http://msdn.microsoft.com/zh-cn/library/office/ee861525.aspx

PowerPoint 解决方案
http://msdn.microsoft.com/zh-cn/library/vstudio/bb772069.aspx

 

相关博客资料:
C# PowerPoint操作的基本用法
http://www.cnblogs.com/hyruur/archive/2011/02/14/1954118.html

VSTO简介及其部署
http://blog.csdn.net/v_jzho/article/category/339472

我的VSTO之路系列
http://www.cnblogs.com/izualx/tag/VSTO/

探索 Word 2007 开发
http://www.cnblogs.com/allenlooplee/category/104575.html

Excel 二次开发系列
http://www.cnblogs.com/tomin/category/209011.html

VSTO项目开发
http://www.cnblogs.com/2018/category/249767.html

VSTO对象操作
http://blog.csdn.net/tianyu0910/article/category/703094

VSTO学习笔记
http://www.cnblogs.com/brooks-dotnet/category/233027.html

 

调用自定义任务窗格

主要是如何去调用自定义任务窗格:Globals.ThisAddIn.myCustomTaskPanel,然后就是对其进行控制操作(自定义任务窗格可以很好的实现类似WPS的素材库呈现的功能)。

获取当前演示文稿的所有幻灯片

如何去获取当前演示文稿的所有幻灯片:Globals.ThisAddIn.Application.ActivePresentation.Slides

 

添加文字、添加图片、添加多媒体对象、OLE对象

主要由 PowerPoint.Shape对象控制

每个 Shape 对象都代表绘图层中的一个对象,如自选图形、任意多边形、OLE 对象或图片。

 

///

       /// 添加TextBox文本框

       ///

       /// 要添加文本框的幻灯片

       /// 文本框显示内容

       private void AddTextBox(PowerPoint.Slide slide, string textContent)

       {

           PowerPoint.Shape textbox;

           textbox = slide.Shapes.AddTextbox(Office.MsoTextOrientation.msoTextOrientationHorizontal,50, 100, 600, 50);//向当前PPT添加文本框

           textbox.TextFrame.TextRange.Text = textContent;//设置文本框的内容

           textbox.TextFrame.TextRange.Font.Size = 48;//设置文本字体大小

           textbox.TextFrame.TextRange.Font.Color.RGB =Color.DarkViolet.ToArgb();//设置文本颜色

       }

 

       ///

       /// 添加图片

       ///

       ///

       ///

       ///

       private void AddADPicture(PowerPoint.Slide slide, PowerPoint.Shapeshape, string filePath)

       {

           PowerPoint.Shape pic;

           pic = slide.Shapes.AddPicture(filePath, Office.MsoTriState.msoFalse,Office.MsoTriState.msoTrue, shape.Left, shape.Top, shape.Width, shape.Height);

           pic.Name = "AD" + shape.Name;//

       }

 

       ///

       /// 添加音频\视频文件

       ///

       ///

       ///

       ///

       private void AddMediaObj(PowerPoint.Slide slide, PowerPoint.Shape shape,string filePath)

       {

           PowerPoint.Shape media;

           media = slide.Shapes.AddMediaObject(filePath, shape.Left, shape.Top,shape.Width, shape.Height);

           media.Name = shape.Name;

       }

 

       ///

       /// 通过文件路径添加OLE对象

       ///

       ///

       ///

       ///

       private void AddClassOLEObj(PowerPoint.Slide slide, PowerPoint.Shapeshape,string className)

       {

           PowerPoint.Shape oleObj;

           oleObj=slide.Shapes.AddOLEObject(Left:shape.Left,Top:shape.Top,Width:shape.Width,Height:shape.Height,ClassName:className);

           oleObj.Name = shape.Name;

       }

 

       ///

       /// 通过ClassName添加OLE对象

       ///

       ///

       ///

       ///

       private void AddFileOLEObj(PowerPoint.Slide slide, PowerPoint.Shapeshape, string fileName)

       {

           PowerPoint.Shape oleObj;

           oleObj = slide.Shapes.AddOLEObject(Left: shape.Left, Top: shape.Top,Width: shape.Width, Height: shape.Height,FileName:fileName);

           oleObj.Name = shape.Name;

       }

 

幻灯片中shapes的遍历处理

PowerPoint.Slides slides =Application.ActivePresentation.Slides;//获取当前演示文稿所有幻灯片

           if (!IsHandler(slides))//所有对象是否处理过

           {

                for (int i = 1; i <=slides.Count; i++)

                {

                    PowerPoint.Slide slide =slides[i];

                    PowerPoint.Shapes shapes =slide.Shapes;

                    int count = shapes.Count;//元素集合总数是变化的

                    for (int j = 1; j <=count; j++)

                    {

                        if(shapes[i].Name.Contains("PPT"))

                        {

                            shapes[j].Visible =Office.MsoTriState.msoFalse;//将其隐藏

                            string picPath ="c:\\AD.jpg";//

                            AddPicture(slide,shapes[j], picPath);//替换图片

                        }

                    }

                }

            }

 private void AddPicture(PowerPoint.Slideslide, PowerPoint.Shape shape, string filePath)

       {

           PowerPoint.Shape pic;

           pic = slide.Shapes.AddPicture(filePath, Office.MsoTriState.msoFalse,Office.MsoTriState.msoTrue, shape.Left, shape.Top, shape.Width, shape.Height);

           pic.Name = "AD" + shape.Name;

       }

鼠标移入控件提示信息

string ScreenTip { get; set; } 控件名信息,加粗

 string SuperTip { get; set; } 控件的具体功能描述

 

 

PPT保存

   ///

       /// ppt另存

       ///

       ///path">

       ///fileName">

       publicvoid PPTSave(string path, string fileName)

       {

            if (!Directory.Exists(path))

            {

                Directory.CreateDirectory(path);

            }

 

            objPresSet?.SaveAs(path +fileName);

       }

PPT插入

///

       /// ppt插入

       ///

       ///target">

       ///startIndex">=-1插入尾部

       ///source">

       publicvoid PPTInsert(POWERPOINT.Presentation target, intstartIndex,POWERPOINT.Presentation source)

       {

          

            foreach (POWERPOINT.Slide oSlide in source.Slides)

            {

                oSlide.Copy();

                POWERPOINT.SlideRange targetSlideRange =target.Slides.Paste(startIndex);

                targetSlideRange.Design =oSlide.Design;

                targetSlideRange.ColorScheme =oSlide.ColorScheme;

  if (oSlide.FollowMasterBackground== OFFICECORE.MsoTriState.msoFalse)

                    {

//自定义PPT背景时,使用

}

                if (startIndex != -1)

                {

                    startIndex++;

                }

            }

       }

 

在 Office 中自定义功能区

https://support.office.com/zh-cn/article/%e5%9c%a8-Office-%e4%b8%ad%e8%87%aa%e5%ae%9a%e4%b9%89%e5%8a%9f%e8%83%bd%e5%8c%ba-00f24ca7-6021-48d3-9514-a31a460ecb31?NS=POWERPNT&Version=16&SysLcid=2052&UiLcid=2052&AppVer=ZPP160&HelpId=124&ui=zh-CN&rs=zh-CN&ad=CN

 

 

https://msdn.microsoft.com/zh-cn/library/bb386097.aspx

 

XML方式创建Ribbon并自定义图标

http://blog.51cto.com/yangfandev/1404925

 

 

可使用对象详细描述 (PowerPoint)

https://msdn.microsoft.com/zh-cn/VBA/PowerPoint-VBA/articles/shape-object-powerpoint

 

隐藏指定的选项卡和选项卡中的组

http://club.excelhome.net/thread-1029454-1-1.html

 

 

VSTO addin 安装部署

http://blog.csdn.net/tpriwwq/article/details/16968511

 

 

VSTO开发参考网站

http://club.excelhome.net/thread-1216526-1-1.html

 

你可能感兴趣的:(VSTO)