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
17
votes
3 answers

Set data type like number, text and date in excel column using Microsoft.Office.Interop.Excel in c#

I am trying to set the data type to an excel column in C#, in this case the data types number, text and date. How does one set a format to an entire excel column?
Jack1987
  • 727
  • 1
  • 14
  • 26
15
votes
1 answer

Reading Outlook Mail with C#

I am using the following code as I attempt to connect to my Outlook mail. Now, I must be doing something wrong because I try to get the inbox mails and I always get 0 mails (when this is not the case). This is my code …
Soph
  • 2,895
  • 5
  • 37
  • 68
15
votes
2 answers

Detecting a password-protected document

Is there any way to know whether a doc/ppt/xls file is password-protected even before opening the file?
logeeks
  • 4,849
  • 15
  • 62
  • 93
15
votes
6 answers

Fastest way to write cells to Excel with Office Interop?

I am writing a function to export data to Excel using the Office Interop in VB .NET. I am currently writing the cells directly using the Excel worksheet's Cells() method: worksheet.Cells(rowIndex, colIndex) = data(rowIndex)(colIndex) This is…
davidscolgan
  • 7,508
  • 9
  • 59
  • 78
15
votes
4 answers

Outlook interop PrintOut document name

We use Outlook interop method MailItem.PrintOut() to print a mail message from Outlook. It is always printed with name "Microsoft Outlook - Memo Style". "Memo Style" here is a print style which Outlook automatically picks for printing. Is there any…
keaukraine
  • 5,315
  • 29
  • 54
14
votes
2 answers

C# Create Excel workbook with 1 sheet by default

I'm trying to create an Excel file with C# COM interop but seems it create it by default with 3 sheets instead of empty or only one. What is needed to create it Empty or just with one: Excel.Application xl = null; Excel._Workbook wb = null; //…
Moti
  • 897
  • 4
  • 12
  • 21
14
votes
3 answers

support different Office versions with Office Automation

We created an application that uses Office 2007 (Excel 2007) to read in data from an Excel worksheet. However. I noticed that when I want to deploy the application on a system with Office 2003 installed, it crashes because other PIA's (and other…
Chris
  • 315
  • 3
  • 7
14
votes
8 answers

Delete Empty Rows with Excel Interop

I have user supplied excel files that need to be converted to PDF. Using excel interop, I can do this fine with .ExportAsFixedFormat(). My problem comes up when a workbook has millions of rows. This turns into a file that has 50k+ pages. That would…
Chris
  • 4,393
  • 1
  • 27
  • 33
14
votes
5 answers

How can I quickly up-cast object[,] into double[,]?

I using Microsoft.Office.Interop.Excel I get returned a 2D array of type object[,] which contains double for elements. Note that the index lower bound is 1 instead of the default 0, but I can deal with that easily. How can nicely convert the array…
John Alexiou
  • 28,472
  • 11
  • 77
  • 133
14
votes
4 answers

VSTO custom taskpane on multi DPI system shows content twice

I am building an office addin using VSTO. On systems with multiple monitors with different DPI settings, the contents of my custom task pane is drawn twice on the monitor with the higher DPI settings: Only the smaller version is actually responding…
Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
14
votes
3 answers

How To Write To A OneNote 2013 Page Using C# and The OneNote Interop

I have seen many articles about this but all of them are either incomplete or do not answer my question. Using C# and the OneNote Interop, I would like to simply write text to an existing OneNote 2013 Page. Currently I have a OneNote Notebook,…
B17
  • 558
  • 1
  • 6
  • 21
14
votes
5 answers

c# word interop find and replace everything

I have some code to replace text inside a word 2010 docx. object fileName = Path.Combine(System.Windows.Forms.Application.StartupPath, "document.docx"); Microsoft.Office.Interop.Word.Application wordApp = new…
14
votes
2 answers

How to open Outlook's new mail window with prepopulated attachment

I need to open a new email window with a prepopulated attachment when a user clicks some button or link in my application.
Selvakumar
  • 360
  • 1
  • 3
  • 17
14
votes
3 answers

Proper disposal of COM interop objects in C# particularly MS Office applications

I am developing an application that relies heavily on multiple Microsoft Office products including Access, Excel, Word, PowerPoint and Outlook among others. While doing research on interop I found out that starting with VS2010 and .NET 4, we…
Raheel Khan
  • 14,205
  • 13
  • 80
  • 168
13
votes
2 answers

microsoft.interop.excel Formatting cells

I am building a report using the microsoft.interop.excel library in C#. I have something like this: Range rangeTarget; . . . rangeTarget = worksheet.get_Range("C" + row, "N" + row); I want the range to display its values as whole numbers i.e.…
Jonny
  • 2,787
  • 10
  • 40
  • 62