office-interop

How to replace image of a picture shape in PowerPoint?

天涯浪子 提交于 2019-12-13 03:34:28
问题 Is there any way to replace the image of an existing picture shape in PowerPoint from code? Thanks 回答1: If it's a linked image, either overwrite the linked image file with a new file or point the link at a new file. Or if the shape is picture filled, you can fill it with a different picture instead. That can distort the picture if its proportions don't match the shape's proportions; instead, you can change the aspect ratio of the shape to match that of the picture if need be. To change the

Setting Word 2007 table style designs in code

雨燕双飞 提交于 2019-12-13 03:12:27
问题 I am generating a Word document using Microsoft.Office.Interop.Word. In that word document I am generating a table. I would like to set the table style to one of the nice table design presets in Word 2007+ with alternating row colors, etc. Rather than setting all the style properties myself, is there an easier way to do this (preset name or some style snippet repository)? 回答1: Nevermind, I found it in the manual. Solution: object tableStyle = WdBuiltinStyle.wdStyleTableLightShadingAccent1;

Delete contents of bookmark without deleting bookmark in ms word using c#

谁说胖子不能爱 提交于 2019-12-13 00:38:19
问题 In ms word2010 I have a bookmark with bookmark name: nameOfBookmark Now the bookmark content could be anything from just text to a mix of pictures, tables and whatever you could think of putting in a word document. The problem is as following: I've got my bookmark with some contents I want to delete. However each time I try to delete the contents it also deletes my bookmark which I want to keep. I've tried this, which simply deletes the whole thing: public void cleanBookmark(string bookmark)

Convert Interop Color to System.Drawing.Color

為{幸葍}努か 提交于 2019-12-12 20:54:45
问题 I am looking how to convert Microsoft.Office.Interop.Word/Excel/PowerPoint.Color to System.Drawing.Color in C#. I have found the contrary in this forum here or here but I don't find how to convert from Interop Color to System.Drawing.Color. I have understood that Interop color is expressed in RGB considering: RGBvalue = Red + 256*Green + 256*256*Blue but it is not very easy from a RGBvalue to find the value of Red Green Blue (for example if the value is 5652 I don't know how to find Red is 20

PowerPoint Interop Assemblies Slowness Issue

随声附和 提交于 2019-12-12 19:13:40
问题 I'm using MS Office interop assemblies to build a Powerpoint addin that inserts slides and charts on the fly. But during insertion it take up to 20 seconds to complete the process from inserting the slide to insertion of the chart. After doing extensive logging, I noticed few lines of code where our application gets stuck for 20+ seconds. Here are those lines: powerpointChartObj.SetSourceData(Source:=String.Format("=Sheet1!A1:B{0}", 5)) powerpointSlideObject.Shapes("some shape name") We

F# Excel UsedRange has no Properties or Methods

。_饼干妹妹 提交于 2019-12-12 18:04:03
问题 This is a continuation of the discussion begun on F# Excel UsedRange is not Defined, which has been solved by down-casting the ActiveSheet object to a Worksheet. Upon doing that, however, I was presented with a new problem: UsedRange exposes no properties or methods other than the standard object methods. My solution has references to Microsoft.Office.Interop.Excel and Microsoft.Office.Tools.Excel.v4.0.Utilities. open Microsoft.Office.Interop.Excel open Microsoft.Office.Tools.Excel let xl =

Bring spell check window to foreground with JavaScript/JScript in Windows 7

我们两清 提交于 2019-12-12 17:00:56
问题 I have some JScript code (converted from some old VBScript) that starts like this: var Word = new ActiveXObject("Word.Basic"); Word.FileNew(); // opens new Word document Word.Insert(IncorrectText); Word.ToolsSpelling(); // opens spell check behind IE The idea is to utilize the MS Word spell check for browser use, and it works well in XP, but the spell check box opens in the background in Windows 7 / IE 8 (this question tells me that the problem started in Vista and is probably an OS issue,

Identify unique references to objects from Interop Libraries (Doument.Paragraphs, etc)

时光怂恿深爱的人放手 提交于 2019-12-12 16:33:19
问题 I would like to be able to identify when two interop variable objects refer to the same "actual" object. By "actual", I mean for example a given paragraph or footnote in a Microsoft Word document. Example in vb: (note c# answers are ok too, the question is not language related) Imports Microsoft.Office.Interop Sub Tests() Dim WordApp as Word.Application = Globals.ThisAddIn.Application Dim ThisDoc as Word.Document = WordApp.ActiveDocument Dim ThisSelection As Word.Selection = ThisDoc

Retain the source template when saving slides in ppt

孤街浪徒 提交于 2019-12-12 15:45:42
问题 I am trying to save selected slide so it doesnt retain my source template. how do i retain the existing template while i save the slides private void SaveSelectedSlide_Click(object sender, RibbonControlEventArgs e) { try { PowerPoint.Application ppApp = Globals.ThisAddIn.Application; PowerPoint.SlideRange ppslr = ppApp.ActiveWindow.Selection.SlideRange; string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); var temporaryPresentation = Globals.ThisAddIn.Application

core 2.0 and office interop - where is the microsoft.office.core package?

自闭症网瘾萝莉.ら 提交于 2019-12-12 14:05:13
问题 In a standard .NET app, I can add the COM objects for Office Core, Word, Excel, and Powerpoint. Everything works fine. The Office core assembly is needed for some commands (for example, powerpoint uses Office.Core.MsoTriState.msoFalse/True commands for some actions, and word uses AutomationSecurity via Office.Core.MsoAutomationSecurity. The problem is when I am building an asp net core app. Nuget has the packages for Excel, Word, and Powerpoint, which will work properly if I don't reference