office-interop

Simple way to Export DataGridView to Excel

纵然是瞬间 提交于 2019-12-09 12:11:38
问题 I am trying to copy DataGridView data to Excel and I am using this code: public static void ExportToExcel(DataGridView dgView) { Microsoft.Office.Interop.Excel.Application excelApp = null; try { // instantiating the excel application class object misValue = System.Reflection.Missing.Value; excelApp = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbook currentWorkbook = excelApp.Workbooks.Add(Type.Missing); Microsoft.Office.Interop.Excel.Worksheet

Creating statecharts in Visio using c#

我是研究僧i 提交于 2019-12-08 19:28:24
问题 Can anyone point me to an example of how to programatically create a statechart in visio? I can create blank pages, drop shapes, open template etc, but when I try to add transitions it complains that the page is not the right type. Can't find a sample anywhere. Alternatively: I can save the user actions to create the chart as a macro. Can I run that programatically? Thanks. < edit > Step away from the PC for 2 minutes and you realise you should have put the code snippet in the question and

How can I compare Word Interop objects for “reference equality” AND determine collection or parent object to which, say, a paragraph belongs?

拟墨画扇 提交于 2019-12-08 19:16:55
问题 I would like to be able to: compare Word Interop COM proxies on a "reference equality" basis; and map from a specific object (say a paragraph) to the collection it comes from, OR at least determine whether two paragraphs are from the same section and which one comes relatively before the previous one Why do I want to do this? I am trying to build a Word Add-In that acts similarly to a spell-checker in the sense that it runs in the background (by background I mean by regularly stealing time

Excel still running after close vb.net app

偶尔善良 提交于 2019-12-08 11:36:51
问题 I'm having some problems closing Excel files. I am doing a program that opens some Excel files, uses the information and then close them. I tried some different codes, but they didn't work because the EXCEL process is still running. My first code: Dim aplicacaoexcel As New Excel.Application Dim livroexcel As Object Dim folhaexcel As Excel.Worksheet livroexcel = aplicacaoexcel.Workbooks.Open("C:\Users\LPO1BRG\Desktop\Software Fiabilidade\Tecnicos.xlsx", UpdateLinks:=False, ReadOnly:=False,

Add hyperlink to smartart node with interop-excel in c#

一笑奈何 提交于 2019-12-08 11:25:43
问题 I have an c# console application which create an excel worksheet containing a smartart object with the hiearchy layout(OrgChart). I would like to add hyperlinks to the nodes within the org chart, but somehow i can't. In the picture below, i would like to add a hyperlink to "Node 1"(1) which will take me to the "LinkedSheet" sheet(2): with the following code snippet, i tried to add a hyperlink to the sheet "orgChart" where the textFrame of "Node 1"(var name: ndTop) is the anchor and the sheet

Customize “New” tab in Word backstage to add custom templates

我是研究僧i 提交于 2019-12-08 10:40:02
问题 I want customize Word's backstage to add custom templates in "New" tab and not another. Templates come from a web service. I use Office 2010. Application is develop in C# with Visual Studio 2010. Is it possible? 回答1: You can add custom templates to the New tab of Word's backstage view by providing an XML manifest, which describes the template and the location of a preview image. The detailed steps are described here: Deploy custom templates in the 2007 Office system Be aware though that this

System.Runtime.InteropServices.COMException (0x800A1436)

浪尽此生 提交于 2019-12-08 09:36:57
问题 We are trying to open a Word template which resides on a Shared Drive using Office Interop Services on an MVC application.The solution is working locally, but once is deployed to the server the following message appears: The File was not created: System.Runtime.InteropServices.COMException (0x800A1436): This file could not be found ApplicationPool is running under a domain user account which already has permissions on the shared drive. Any suggestion? 回答1: You may consider using the Open XML

Add watermark image in c#

三世轮回 提交于 2019-12-08 07:14:37
问题 I have this little code to add a watermark image in a doc file, only have a little issue, if i convert it one time it works ok, but if i try to convert another file gives me this error: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) in this line: wordFile = oWord.Documents.Open(row.filename); This is my code: Microsoft.Office.Interop.Word.Application oWord = new Microsoft.Office.Interop.Word.Application(); Document wordFile = new Document(); //OTHER VARIABLES Object

COM typelibrary for Office 2010 IM integration

↘锁芯ラ 提交于 2019-12-08 07:04:33
问题 I am integrating Office applications with custom IM solution. I have implemented the COM class as suggested by http://msdn.microsoft.com/en-us/library/office/jj900715.aspx I have also registered the COM implementation and hosted the COM server in my exe. Do I also need to additionally register the typelibrary of my com class ? I am seeing issues with type library regsitration and lync client 2013. When I uninstall the type library, Lync Client breaks Generic COM Exception. Code is 0x80080005.