office-interop

Communicating between C# and VBA

我是研究僧i 提交于 2019-11-30 04:03:42
问题 At the request of my boss I created a small set of scripts that are used to periodically monitor the status of certain devices and processes. This info is subsequently processed using a relatively elaborate VBA module that gathers all info, applies formulas, sets up ranges and generates graphs, etc. There are two problems however: I'm an amateur programmer, so my VBA routine is quite inefficient. That's not a huge problem for me (I just get up and get a coffee while it's running), but for

Filling fields in Word using c# and Microsoft Word Interop

不想你离开。 提交于 2019-11-30 01:49:08
问题 I tried to Fill out Form Fields in Microsoft Word using C# Interop Assemblies with the following Code string filename = @"N:\mehler\Vorlage2.dotx"; Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application(); Microsoft.Office.Interop.Word.Document doc = new Microsoft.Office.Interop.Word.Document(); doc = word.Documents.Open(filename); doc.Activate(); foreach (Microsoft.Office.Interop.Word.FormField field in doc.FormFields) { switch (field.Name) { case

Cannot debug or run Word AddIn because the required version of Microsoft Office is not installed

你。 提交于 2019-11-29 22:51:09
I need to work on an existing Word 2007 addIn project that's a part of a MSVS 2008 solution. However, when I try to debug the addIn, I get the following error message: "You cannot debug or run this project, because the required version of the Microsoft Office application is not installed". I have Office 2007 installed. I tried creating a new Word 2007 addIn project in the same solution, and I have no problem debugging it. As far as I can tell, all the referenced Office assemblies are the same between these two projects. Referenced Office assemblies: Microsoft.Office.Interop.Word (c:\Program

VSTO Unit Testing Office AddIn in C# .NET via RequestComAddInAutomationService

允我心安 提交于 2019-11-29 20:38:34
问题 I have worked and read through various StackOverflow questions and other tutorials and documentation over the past weeks (N.B. some of them below) to try and find a way of unit testing a VSTO AddIn. Unfortunately, it always results in an E_NOINTERFACE exception in my tests. The code I am using is below - one extract of the ThisAddin partial class overriding the RequestComAddinAutomationService , another describing the test utility interface, the test itself, as well as an additional assembly

how to make the Outlook Compose window top most?

浪尽此生 提交于 2019-11-29 17:59:13
I am creating an Outlook Message. Sometimes the Outlook Compose window appears behind other windows. How can I make it the top most? String address = "someone@example.com"; Outlook.Application oApp = new Outlook.Application(); Outlook._MailItem oMailItem = (Outlook._MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem); oMailItem.To = address; oMailItem.Subject = "Help"; oMailItem.BodyFormat = Outlook.OlBodyFormat.olFormatPlain; oMailItem.Attachments.Add("H:\\file.txt"); oMailItem.Body = "Call me"; // body, bcc etc... oMailItem.Display(true); I am using WinForm and .Net 2.0 (target) Firstly,

How can fill I cells A1:A5 with a color using C#?

拟墨画扇 提交于 2019-11-29 16:52:18
I have the following code: Excel.Range chartRange; chartRange = xlWorkSheet.get_Range("A3", "R3"); I want to fill this range of cells with a color. I have already tried with: System.Drawing.Color = "yellow" but it is throwing an exception that an object reference is required. How can I fix my code to fill these cells with a color? Try this: chartRange.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Yellow); The problem with your code shown above is that you can't assign the string value "Yellow" to the System.Drawing.Color type. Instead, the standard colors are

How can I read MS Office files in a server without installing MS Office and without using the Interop Library?

孤人 提交于 2019-11-29 14:55:43
问题 The interop library is slow and needs MS Office installed. Many times you don't want to install MS Office on servers. I'd like to use Apache POI, but I'm on .NET. I need only to extract the text portion of the files, not creating nor "storing information" in Office files. I need to tell you that I've got a very large document library, and I can't convert it to newer XML files. I don't want to write a parser for the binaries files. A library like Apache POI does this for us. Unfortunately, it

Access excel cell by its name

拜拜、爱过 提交于 2019-11-29 14:43:14
I'm trying to set excel's cell name to some custom name and to later access that cell by its name. Is there some out of the box API call to do this, or how should I do this if I have information of worksheet and cell name in case of accessing cell and worksheet and cell address (i.e. C2) in case of naming the cell. Also to ask, is there a way to acquire formatting information that is bound to that specific cell? (i.e. When I'm accessing cell by name I want to return cell value and some formatting properties of this cell, if cell is number or text, is it highlighted, etc...) regards, Vladimir

Installing VSTO 4.0 Causes VSTO 3.0 Addin to quit working

放肆的年华 提交于 2019-11-29 14:31:34
问题 I just installed Visual Studio 2010 yesterday. As part of that I installed VSTO 4.0. Now when I run any Office application, my VSTO 3.0 addins fail to load. The error in the event log is Customization URI: file:///H:/PathToMyAddin/MyAddin.vsto Exception: Customization does not have the permissions required to create an application domain. Microsoft.VisualStudio.Tools.Applications.Runtime.CannotCreateCustomizationDomainException: Customization does not have the permissions required to create

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

限于喜欢 提交于 2019-11-29 10:55:13
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. This behavior is "by design" and Microsoft is not interested in changing. This is the way the UI functions. What you could do would be to create the chart in Excel (using either the interop or OpenXML), then import