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
9
votes
2 answers

Copy text from word file to a new word

I am reading the text from word file and replace some text from the readed text. var wordApp = new Microsoft.Office.Interop.Word.Application(); object file = path; object nullobj = System.Reflection.Missing.Value; var doc =…
huMpty duMpty
  • 14,346
  • 14
  • 60
  • 99
9
votes
1 answer

How to create Microsoft.Office.Interop.Word.Document object from byte array, without saving it to disk?

How can I create a Microsoft.Office.Interop.Word.Document object from byte array, without saving it to disk using C#? public static int GetCounterOfCharacter(byte[] wordContent) { Application objWord = new Application(); …
Masoomian
  • 740
  • 1
  • 10
  • 25
9
votes
1 answer

Passing integers to VSTO 2010 Word Addin

I am trying to develop a VSTO 2010 Word Addin. It has a custom task pane with a countdown timer (user control) in it. Idea is that when a word document is opened total time (in hours and minutes) is passed to the Addin which in turn passes it to the…
9
votes
2 answers

GetOccurrence always throws exception

I have been trying to get appointments from outlook via the Outlook interop classes. Specifically those that are reoccurring appointments. I have tried using both v12 and v14 of the interop libraries with the same results. The following code always…
Sen
  • 1,438
  • 2
  • 12
  • 19
9
votes
1 answer

When do I need to call ReleaseComObject?

In a Microsoft Office AddIn we are passed COM objects in events. To take a specific case, when Word opens a document we are called and passed a Document object. So when do we need to call Marshal.ReleaseComObject()? If we access the Document object…
David Thielen
  • 28,723
  • 34
  • 119
  • 193
8
votes
3 answers

Office documents to PDF

I have seen a couple threads about this, but am not getting very straight answers in my searching. I have a web application that needs to take in doc, docx, xls, xlsx files and convert them into PDF. Right now we have a process that uses the…
Justin Rassier
  • 898
  • 12
  • 26
8
votes
1 answer

Inserting image content from Rest API to currently opened document in Microsoft Word

Edit: This question's text has been changed to reflect utilizing open xml code and interop. I'm trying to insert a base 64 encoded image to a Word document via a ribbon. The following code is for reproduction purposes: public partial class…
C Bauer
  • 5,003
  • 4
  • 33
  • 62
8
votes
1 answer

Cannot add reference to Outlook 2016 (Office 365) Interop (16.0.0.0)

I'm trying to add a reference to 'Microsoft Outlook 16.0 Object Library' in a C# .NET 4.6.1 WPF project, because I have office 2016 installed. Previous versions of the Object Library are incompatible with the 2016 version of office. If I use Excel's…
8
votes
5 answers

Looking up the value for MS Office Interop constants rather than hard coding them

Using PowerShell, it is easy enough to create, say, an instance of the Excel Application class and start manipulating it: $app = New-Object -ComObject "Excel.Application" However, if I need to use the constants like xlDoubleQuote or xlDelimited -…
Goyuix
  • 23,614
  • 14
  • 84
  • 128
8
votes
4 answers

C# Excel Interop Slow when looping through cells

I am trying to extract all text data from an Excel document in C# and am having performance issues. In the following code I open the Workbook, loop over all worksheets, and loop over all cells in the used range, extracting the text from each cell as…
pwwolff
  • 606
  • 1
  • 5
  • 20
8
votes
1 answer

Showing error when password protected OpenXml Word document get resaved as a password protected binary Word in office 2010

In microsoft word i have created openxml.doc(*.docx) file given credentials 'abc' as Readpassword and 'xyz' as WritePassword. Now i have to convert openxml.doc to binary.doc(WdSaveFormat=0) the document is created sucessfully as Binary.doc using…
ND's
  • 2,155
  • 6
  • 38
  • 59
8
votes
1 answer

Using Interop.Word, is there a way to do a replace (using Find.Execute) and keep the original text's justification?

I'm attempting to write find/replace code for Word documents using Word Automation through Interop.Word (11.0). My documents all have various fields (that don't show up in Document.Fields) that are surrounded with brackets, eg., needs to be…
AJ.
  • 16,368
  • 20
  • 95
  • 150
8
votes
3 answers

Bring Word Application to Front

I programmatically create a Word document and ask the user if he want's to display the document right now. In order to bring the document to front I minimize and maximize the document. The document comes to front of screen but in an 'impolite'…
user3041065
  • 185
  • 2
  • 9
8
votes
2 answers

How can I create an Outlook PST file using .Net?

I'm writing an app that will manipulate Outlook data. I want to make a backup of that data first and am hoping I could just loop through the contact/calendar items, etc and write them out to a PST file. How can I write the contents of 1 or several…
brendan
  • 29,308
  • 20
  • 68
  • 109
8
votes
4 answers

Communicating between C# and VBA

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…
romatthe
  • 1,447
  • 3
  • 17
  • 33