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
12
votes
5 answers

using c# to select a worksheet in excel

Using C# in .NET 3.5 with Visual Studio 2008, I am trying to set focus (or activate) a specific worksheet in an open workbook: Here are some properties: public Excel.Application xlApp {get;set;} public Excel.Workbook xlWorkBook { get; set; } public…
Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062
11
votes
7 answers

List fonts used by a Word Document (faster method)

I am working on a process for validating documents to make sure that they meet corporate standards. One of the steps is to make sure that the Word document does not use non-approved fonts. I have the following stub of code, which works: Dim…
Peter
  • 9,643
  • 6
  • 61
  • 108
11
votes
2 answers

The range cannot be deleted. at Microsoft.Office.Interop.Word.Range.set_Text(String prop)

The recommended c# .net code to replace a bookmark with text appears very straight forward and I have seen the same code all over the net on so many websites (including yours, from a Sept. 2009 post) however, I cannot get past the error The range…
dan
  • 111
  • 1
  • 4
11
votes
1 answer

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

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…
JDR
  • 1,094
  • 1
  • 11
  • 31
11
votes
2 answers

disabling overwrite existing file prompt in Microsoft office interop FileSaveAs method

I am using Ms Office Interop assemblies to create a MS Project file. To save the file created, I am using FileSaveAs method and it prompts a message saying that if you want to replace the existing file. I want to suppress the message, and I didn't…
Elangovan
  • 1,449
  • 2
  • 23
  • 41
11
votes
5 answers

Unable to cast COM object of Office Interop Word

My application has a feature to export to Microsoft Word, but it hasn't worked since I've upgraded from Microsoft Office 2010 to Microsoft Office 2013. Here is the code: Microsoft.Office.Interop.Word.Application appVersion = new…
aiyagaze
  • 884
  • 2
  • 8
  • 14
11
votes
2 answers

Add a row to an MS Word table using Microsoft.Office.Interop

I have a word template with a table that I am populating from a list of strings that I split using tab characters. I do not know how many lines of text I will have as it will vary. So I am adding a row programmatically before iterating through my…
Our Man in Bananas
  • 5,809
  • 21
  • 91
  • 148
11
votes
3 answers

programmatically excel cells to be auto fit width & height

when i convert datatable to .csv my excel sheets are generated as below: and tried like below: sw.Write(string.Format("=\"{0}\"", drow[i].ToString())); then my excel sheets were like: note that cells have =" " characters; i'm trying to do like…
Sankar M
  • 4,549
  • 12
  • 37
  • 55
11
votes
5 answers

Fastest way to get an Excel Range of Rows

In a VSTO C# project I want to get a range of rows from a set of row indexes. The row indexes can be for example like "7,8,9,12,14". Then I want the range "7:9,12,14" rows. I now do this: Range rng1 = sheet.get_Range("A7:A9,A12,A14",…
Gayan Dasanayake
  • 1,933
  • 2
  • 17
  • 22
11
votes
3 answers

Get instance of Excel application with C# by Handle

I have a c# simple application that have to write some values in a excel ranges of a specific worksheet. I create an instance of Excel application if not exist, but if exist i want to set active it and take an instance if it to use in my code. I use…
Babba
  • 253
  • 1
  • 5
  • 12
11
votes
5 answers

HTMLBody refuses to output the font size I specify, always ends up a different size

I'm trying to get my C# application to generate form emails. I should have had this wrapped up in an hour on Friday...but Outlook is being quite disobedient. It seems that no matter the way I specify the font size in the MailItem's HTMLBody, it…
friggle
  • 3,362
  • 3
  • 35
  • 47
10
votes
2 answers

Microsoft Interop: Excel Column Names

I am using Microsoft Interop to read the data. In excel-sheet the column-names are like A,B,C,D,....,AA,AB,.... and so on. Is there any way to read this column-names? If you need any other info please let me know. Regards, Priyank
Priyank Thakkar
  • 4,752
  • 19
  • 57
  • 93
10
votes
3 answers

Is it necessary for the build machine to have Microsoft Office 2007 installed?

Our app added functionality to allow users to import certain information from an excel spreadsheet (all users will have Office 2007 already). The development machine has Office 2007 and the developer added a reference to…
Gary Barrett
  • 1,764
  • 5
  • 21
  • 33
10
votes
3 answers

MS Word Automation in C# - Unable to cast object of type 'System.String[*]' to type 'System.String[]'

I use this code to get a String array of headings used in a MS Word 2007 document (.docx): dynamic arr = Document.GetCrossReferenceItems(WdReferenceType.wdRefTypeHeading); Using the debugger, I see that arr is dynamically assigned a String array…
Lasse Christiansen
  • 10,205
  • 7
  • 50
  • 79
10
votes
1 answer

Can not open more than 11 instances of Excel using Excel interop on windows 10

Using Excel Interop in C#, under windows 10 on a Macbook Pro with 16GB of memory, I can't open more than 11 instances of Excel. After the 11th instance, I get the following error in a "popup": "Cannot use object linking and embedding" Here is the…
Aric Lasry
  • 1,769
  • 3
  • 11
  • 11