office-interop

Possible to cast active Microsoft Word window to WPF Window?

痴心易碎 提交于 2019-12-11 03:24:35
问题 I've created a Microsoft Word 2010 vsto add-in which displays a number of custom Wpf Window dialogs when users click on ribbon buttons. The issue I'm having is that the custom dialog dissapears behind the Word instance if you click the Word icon in the task bar. After some Googling it appears that this can be fixed by setting the Owner property of my window, but I'm struggling to get the Window instance of the Word application. I've attached the relevant code below, any suggestions? using

DCOM Config settings for Microsoft Interop Word Automation

你说的曾经没有我的故事 提交于 2019-12-11 03:16:03
问题 I am using Microsoft Office Interop Word to generate documents using C#. In order for the document generation to work, there should be an entry for the "Microsoft Office Word 97 - 2003 Document" under the Dcom Config Settings as shown below: The Local Path under the General Tab has a correct path when Microsoft Office is first installed. If I then join the computer to a Domain, and then restart the system with a Domain user, the Local Path becomes blank and the application doesn't generate

C# - Excel 2013 how to change chart style

老子叫甜甜 提交于 2019-12-11 03:03:47
问题 I'm trying to chnage style for a chart in excel 2013 but it only changes color: Range chartRange; ChartObjects wsCharts = (ChartObjects)workSheet.ChartObjects(Type.Missing); ChartObject myChart = (ChartObject)wsCharts.Add(0, 0, 900, 500); Chart workChart = myChart.Chart; chartRange = workSheet.get_Range("A1", "D12"); workChart.SetSourceData(chartRange, Type.Missing); workChart.ChartType = XlChartType.xlColumnClustered; now the chart looks like this: and then workChart.ChartStyle = 8; changes

Task.Run from UI thread throws STA error

折月煮酒 提交于 2019-12-11 03:03:12
问题 While I was refactoring some old C# code for document generation with Office.Interop library I found this and because of it was using UI context when function were called from it it was blocking it Example private void btnFooClick(object sender, EventArgs e) { bool documentGenerated = chckBox.Checked ? updateDoc() : newDoc(); if(documentGenerated){ //do something } } Decided to change it like that to reduce from blocking UI private async void btnFooClick(object sender, EventArgs e) { bool

Print and resize MATLAB figure in Excel

谁说我不能喝 提交于 2019-12-11 02:53:42
问题 I have two figures in MATLAB with the handles hFig1 and hFig2 . I would like to print them to specific cells in Excel (cells E3 and I3) and reshape them to each be [2in x 3in]. I have tried using the .AddPictures object handler and using print -dmeta , but I can't find a way to achieve all three of my objectives. I am also writing data to excel at the same time and because there is a lot of data lines being sent, I was hoping to have a method that didn't require continually invoking excel

Excel automation failing on server Access Denied / HRESULT: 0x80070005 (E_ACCESSDENIED)

ぐ巨炮叔叔 提交于 2019-12-11 02:38:50
问题 I've got a Windows service working in dev and pre-prod that uses Office interop. I'm attempting to deploy in production (also Server 2008R2) and it's not working when it attempts to start Excel in the first place (create an Application instance). Error: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)). The C:\Windows\SysWOW64

Excel Interop Apply Chart Template

狂风中的少年 提交于 2019-12-11 02:26:47
问题 Problem Overview: I am automating the report generation (excel) for a customer using C# with "native" excel support (microsoft.office.interop.excel) and the EPPlus library. My customer is not very flexible about charts design so my charts must have the exact same style as theirs. No problem, i exported their chart templates using Excel 2010 What does not work: I can't apply any chart template via code What i have tried: 1 - EPPlus : Have no support for loading templates to charts 2 -

Create word document and add image from .NET app

我与影子孤独终老i 提交于 2019-12-11 01:48:15
问题 I need a way of generating a word document (from a template or something) and inserting an image at a specific place. Does anyone have any pointers on the best way to do this? I worked on a project that used Office Automation in .NET 1.1 a few years ago, and it was really unspeakably poor. I'm assuming OA has either been improved or been superceeded by a better solution, but I'm not finding much advice on google. Edit to clarify, this will be running on a web or sharepoint server 回答1:

Word 2010 Templates/Addin/Document passing starting arguments

こ雲淡風輕ζ 提交于 2019-12-11 01:38:34
问题 I'm trying to create a word template or addin as a means to enter data into a form. It will be tied to a database through service calls. I'm wondering if there is a way to start this document by passing it an Id for the record it's tied to. I would like to open up the word document from another .NET program passing it the Id so it knows where to get its data. Is this possible? or am I looking at this all wrong? 回答1: I use Custom Document Properties to store lot of things about the document.

Fastest way to format multiple rows in an excel in C#

☆樱花仙子☆ 提交于 2019-12-11 01:32:57
问题 I have a huge dataset that I want to write into the Excel and need to perform conditional formatting of rows based on a business logic. So, for the data insertion part, I am using a data array to populate the Excel and it works pretty fast. However, I see a severe performance degradation when it comes to formatting the rows. It almost takes more than double the time just to do the formatting. As of now, I am applying formatting to individual rows and loop through a series of rows. However, I