office-interop

word is getting closed for some system

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 11:53:56
问题 I am using word interop api in outlook addins for reading word file. This is working fine for office 2010 with windows 8 and windows 10. but for some of windows 7 (x64) system with office (x86) i am facing problem that word is getting invisible after sometime. I guess this is happening because when i am seeing task manager it opens only one instance and i am doing following operation on word Private Shared ObjwordApp As Word.Application ObjwordApp = New Word.Application() ObjwordApp.Visible =

Excel.Range object not disposing so not Closing the Excel process

有些话、适合烂在心里 提交于 2019-12-24 11:44:05
问题 I am banging my head since hours to dispose the Excel.Range Object creating by the statement below. I Have checked almost all the Discussions regarding it on Stack Overflow. oSheet.Range("A1", "H1").Merge() When i comment out this line Excel Application closes successfully. But when i use this line it creates the Excel.Range object which is not disposing of by GC. Can anyone please help me out. Thanks 回答1: You shouldn't do nested calls like that, instead change it to be something like: Dim r

How to convert an Interop.Word.Document object to a stream or byte array?

天涯浪子 提交于 2019-12-24 11:34:38
问题 I'm trying to upload a word document I have created in memory to Sharepoint 2010 and it looks like the only way to do this is to convert it to a byte array or a stream. Is there anyway I can do this without saving it to disk first? 回答1: this link: http://social.msdn.microsoft.com/forums/en-US/vsto/thread/84f1ac3f-f078-4087-a627-351d6bb57173/ suggests that the correct way is to either copy the document to the clipboard, then stream the data off the clipboard, or... read the document Range's

Distinguish Save and Autosave events in Microsoft Excel Add in

邮差的信 提交于 2019-12-24 11:05:08
问题 I have two Microsoft Excel 2007/2010 C# Addin projects. How can I distinguish regular "Save"/"Save As" commands that are called by user and "AutoSave" event that is periodically invoked by Excel itself? I know that in Microsoft Word I can access AutoSave event via Application.WordBasic object: var oBasic = Application.WordBasic; var fIsAutoSave = oBasic.GetType().InvokeMember("IsAutosaveEvent", BindingFlags.GetProperty, null, oBasic, null); bool isAutoSave = int.Parse(fIsAutoSave.ToString())

Microsoft.Office.Interop.Excel.Application - Invokeing Different Versions of Excel

非 Y 不嫁゛ 提交于 2019-12-24 10:55:53
问题 I have the following issue: var oExcelApp = new Microsoft.Office.Interop.Excel.Application(); On this machine this starts Excel 2016, however I have both Excel 2010 and Excel 2016 installed on my machine. I'd like to start 2010 instead, and I'd like to keep both 2010 and 2016 installed on my machine when I do that. According to this post, it's not possible. However, my understanding is that you can do this programmatically using the following commands: (To register Excel 2010 as the default

MS Word Interop to C# - Inserting multiple files at a bookmark

风格不统一 提交于 2019-12-24 10:48:12
问题 I have one master document into which I want to insert a number of files. These should be inserted into the file one after another at a certain point in the middle of the document. So I have created a bookmark at this point called "TESTS", since this seems to be the easiest way of programatically finding the point. I am able to insert a single file using this code: Microsoft.Office.Interop.Word.Application oWord = new Microsoft.Office.Interop.Word.Application(); Microsoft.Office.Interop.Word

PowerPoint Programming: Indentation with Ruler margin levels not working?

瘦欲@ 提交于 2019-12-24 10:01:02
问题 Recently we upgraded one our PowerPoint addin to support 2007 and 2010. most of the items we were able to port without problem. one problem we have is that indentations doesn't work when create tables or shapes using the addin. for eg: same table gets dropped with proper indentation in 2003 but same thing doesn't get indentation when added to using 2007. below is the code snippet that allows indenting: With PropertyValues.ObjShape.Table.Cell(row, col).Shape.TextFrame.Ruler For rulerCount = 0

Is there a way to tell PowerPoint not to open Excel when creating charts?

 ̄綄美尐妖づ 提交于 2019-12-24 09:39:49
问题 Slide.Shapes.AddChart() automatically opens Excel. Even if I quickly do Chart.ChartData.Workbook.Application.Visible = false , it still shows a little while. This makes automating chart creation error-prone as the user has to try not to touch the Excel applications that keeps popping up. Opening a presentation with WithWindow = false will still open Excel when creating new charts. 回答1: This behavior is "by design" and Microsoft is not interested in changing. This is the way the UI functions.

Pass constructor arguments when deserializing into a List(Of T)

佐手、 提交于 2019-12-24 09:06:48
问题 I need to serialize and deserialize a List(of T) via JSON.Net, where T is an object which contains a reference which cannot be serialized. Here is a simplified version: Class MyObject Private ReadOnly _Parent As Word.Document Property Foo As String Property Bar As String Sub New(Parent As Word.Document, Foo As String, Bar As String) Me.New(Parent) Me.Foo = Foo Me.Bar = Bar End Sub Sub New(Parent As Word.Document) _Parent = Parent End Sub <JsonConstructor> Private Sub New() End Sub Function

Setting word document table cell margin programmatically using c#

*爱你&永不变心* 提交于 2019-12-24 07:36:00
问题 As we can change default table cells margin in MS WORD using this steps Click the table. On the Table menu, click Table Properties, and then click the Table tab. Click Options. Under Default cell margins, enter the new values you want. and exactly I want to ask how to do this programmatically I have tried top and bottom padding properties but it did not work and also I tried spacing but I did not work too so is there any way to set default cell margin using Microsoft.Interop.Word libraries