Questions tagged [office-interop]

Office Interop is the layer using the COM Interop that allows .NET or C# to communicate with standard COM objects and libraries.

Office Interop is the layer using the COM Interop that allows .NET or C# to communicate with standard COM objects and libraries.

3602 questions
10
votes
4 answers

Inserting A Line Break (Not A Paragraph Break) Programatically To A Word Document

I am using the Office Developer Tools for Visual Studio 2013 in C#. Ever since Word 2007, adding a "\n" character adds a paragraph break (which adds more space than the line break in Word). How can I add a line break to a document? I've tried "\n",…
user3731528
  • 333
  • 1
  • 2
  • 9
10
votes
1 answer

How to expose a C# class to a VBA module in a document-level add-in?

This is a hypothetical situation. I would like to find out if it's possible to expose a C# class to VBA in a document-level add-in. Here's an SSCCE: In VS PRO 2012 I have started a new project, Selected Office -> Excel 2010 Workbook. (make sure you…
user2140173
10
votes
2 answers

How to debug slow Office application interop constructor?

I have an application which deals with excel. Recently I encountered a problem with very slow creation of Excel object. I've recreated the issue with this simple code: Microsoft.Office.Interop.Excel.Application xlApp; xlApp = new…
10
votes
5 answers

Adding hyperlinks in Excel[2007] in C# - Within Excel it self

Can anybody tell me how we can add a hyperlink in Excel (2007 or later) from a cell in one sheet to a cell in another sheet using Office Interop in .NET (c#) For example: A hyperlink from Sheet1 Cell A1 to Sheet2 Cell B10
Amit
9
votes
1 answer

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

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…
9
votes
3 answers

Cant get needed assembly loaded on server - Office 2010 Primary Interop

Built a C# Script Component in SSIS referencing Microsoft.Office.Interop.Excel Ver 14. Works fine on my laptop. Now I need to run it on a Win 2008 R2 Server and that assembly does not exist. I downloaded PIARedist.exe Version:14.0.4763.1024 from: …
tvanharp
  • 325
  • 3
  • 11
9
votes
13 answers

Killing EXCEL.exe Process from C# in a Windows Service

I have a windows service that opens up an Excel spreadsheet via the Microsoft.Office.Interop.Excel.Application object. Application xlApp = new Application(); Workbook workbook = xlApp.Workbooks.Open(fileName, 2,…
thiag0
  • 2,199
  • 5
  • 31
  • 51
9
votes
2 answers

Create, insert text and save a Word doc in C#

I've found loads of useful documentation around creating an instance of a word doc, inserting all manner of text and formatting but cannot find anywhere something to save a document that hasnt already been created and opened programmatically.…
Dan
  • 127
  • 2
  • 2
  • 9
9
votes
3 answers

How to update fields in headers and footers, not just main document?

in C#, using wordDocument.Fields.Update() works great on everything in the main body. Any suggestion for concise and elegant way to update the fields in the headers and footers as well?
Gabe
  • 630
  • 1
  • 9
  • 25
9
votes
2 answers

Excel COM Interop - tlbimp vs primary WrapperTool

I'm trying to add the ActiveX Microsoft Excel 11.0 Object library to my .NET project. It works fine on my computer, but when I check in my code, it doesn't work on my coworker's. Fixed it on his and it broke mine. When added, the namespaces are…
Mashmagar
  • 2,556
  • 2
  • 29
  • 38
9
votes
4 answers

Outlook 2007 from C# - COM exception, TYPE_E_LIBNOTREGISTERED

I'm trying to make a program that would open new Outlook 2007 message. I've referenced from COM tab Microsoft Outlook 12.0 ObjectLibrary. These items showed up in references in VS: Microsoft.Office.Core Microsoft.Office.Inerop.Outlook Now I try to…
PK.
  • 588
  • 1
  • 4
  • 12
9
votes
3 answers

WrapText for column in Excel programmatically

I'm trying to set WrapText property to true with C#. Range rng = sheet.get_Range("A:A", System.Type.Missing); rng.EntireColumn.ColumnWidth = 50; rng.EntireColumn.AutoFit(); rng.EntireRow.AutoFit(); rng.WrapText = true; but it doesn't work without…
Max Zhukov
  • 877
  • 1
  • 8
  • 32
9
votes
8 answers

Automating MS Word in Server 2012 R2

Firstly, please don't reply with the generic advice not to automate Word on a server or a link to the MS web page on "how to automate word on a server if you really must". I am aware of this. I have a process which runs as a Windows service and uses…
Andy
  • 10,412
  • 13
  • 70
  • 95
9
votes
2 answers

Get Unique Id From MailItem (Microsoft.Office.Interop.Outlook)?

I'm creating an application that is reading emails received in outlook. The reading process is something like this: using Outlook = Microsoft.Office.Interop.Outlook; var app = new Outlook.Application(); var ns =…
Jonny Piazzi
  • 3,684
  • 4
  • 34
  • 81
9
votes
3 answers

C#: How can I open and close an Excel workbook?

Does anyone know how to simply open and close an Excel workbook? I don't need to read any data from the file, I just need to open and close it. (*) I'm guessing that I'll need to reference the Microsoft.Office.Interop.Excel assembly. *Reason: I've…
Jim G.
  • 15,141
  • 22
  • 103
  • 166