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
6
votes
1 answer

Cannot trap after "Want to save your changes" dialog in Excel

In Word VSTO we have DocumentBeforeSave event which is called right after "Want to save your changes" dialog and I can easy cancel standard Save dialog and show my own. But in Excel VSTO WorkbookBeforeSave is called after Save dialog closed and it…
Sanja Melnichuk
  • 3,465
  • 3
  • 25
  • 46
6
votes
1 answer

Detecting password protected PPT and XLS documents

I found this answer https://stackoverflow.com/a/14336292/1537195 which gave a good way to detect password protection for DOC and XLS files. //Flagged with password if (bytes.Skip(0x20c).Take(1).ToArray()[0] == 0x2f) return true; //XLS 2003 if…
silent
  • 14,494
  • 4
  • 46
  • 86
6
votes
2 answers

Microsoft.Office.Interop.Excel Reference in Build Server

I'm using Microsoft.Office.Interop.Excel reference in the windows service application to create excel reports. The application builds fine in DEV machine but in the build machine it fails saying "The type or namespace name 'Office' does not exist in…
user3220129
  • 503
  • 9
  • 24
6
votes
3 answers

VSTO Word add-in - new document event not firing if Word is launched from the executable

In my add-in, I need to create a task pane for each open document. In the add-in's startup method, I subscribe to the ApplicationEvents4_Event.NewDocument and Application.DocumentOpen events, and then create a task pane for each opened…
sdds
  • 2,021
  • 2
  • 25
  • 33
6
votes
2 answers

Freeze Panes in multiple worksheets C#

I am working on MS Excel 2013 generating report where all the worksheets in workbook should have freeze pane at column 6 and row 1. I have searched on Google but could not find any solution as for freezing the pane, workbook has to be active. I have…
Vbp
  • 1,912
  • 1
  • 22
  • 30
6
votes
1 answer

C# 4.0 dynamic Office interop performance

I've taken an application that was developed in Visual Studio 2008 and used various Office libraries through COM Interop. I began some proof of concept development using the dynamic keyword and Visual Studio 2010. I found that performing the same…
billb
  • 3,608
  • 1
  • 32
  • 36
6
votes
3 answers

How can I duplicate a row in a Word table?

I am trying to duplicate a table row in Word, using VBA, without using the Selection object or the clipboard. That is, I want a new row that has the same content as an existing row. To do this, I first create a new (empty) row, and loop through each…
Gary McGill
  • 26,400
  • 25
  • 118
  • 202
6
votes
3 answers

How to load Word document from byte array

I have the whole MS Word file itself saved into a byte array.A want to load it the way I would if it was on file system but with the minimal use of Microsoft.Office.Interop.Word because it is very slow when it gets the the .Open(args[]) part.
mathinvalidnik
  • 1,566
  • 10
  • 35
  • 57
6
votes
4 answers

How to NOT save documents using microsoft.office.interop.word

Just wondering if anyone knows how to not save a document after creation when using Microsoft.Office.Interop.Word. Basically i am using mail merge to print off a report from c#, the document get made, values are passed to it no problem and i can…
Shaun
  • 175
  • 1
  • 2
  • 8
6
votes
1 answer

Word Automation Find and Replace not including Text Boxes

I have a word document which has a text box. When i run an automated find and replace its matching in the main document, but not match anything in the Text Box. How do i tell the find and replace function to include Text Boxes. Word.Range range =…
Jammy
  • 779
  • 2
  • 13
  • 26
6
votes
2 answers

Retrieve task specific to user from outlook using c#

I'm using the below code to fetch tasks from Outlook 2007. public class c_tasks : IDisposable { private Microsoft.Office.Interop.Outlook.Application objOutlook = null; private Microsoft.Office.Interop.Outlook.NameSpace…
iJade
  • 23,144
  • 56
  • 154
  • 243
6
votes
2 answers

COM Exception 80040154 When creating an Excel Application

I'm trying to run my application on a server which does not and will not have Office installed on it. using EXCEL = Microsoft.Office.Interop.Excel; ... EXCEL.Application app = new EXCEL.Application();//Exception thrown here The code is working…
Bizhan
  • 16,157
  • 9
  • 63
  • 101
6
votes
2 answers

Simple way to Export DataGridView to Excel

I am trying to copy DataGridView data to Excel and I am using this code: public static void ExportToExcel(DataGridView dgView) { Microsoft.Office.Interop.Excel.Application excelApp = null; try { // instantiating the excel…
user1632718
  • 183
  • 1
  • 2
  • 9
6
votes
2 answers

How to set the file name of a word document without saving it from c# and automation

I create word documents via automation and mailmerge with office Interop from c# (.net4). The merge works well and the user receives the created document as he desires. So far all is well. The client now requests, that if he tries to save the…
HCL
  • 36,053
  • 27
  • 163
  • 213
6
votes
2 answers

Determine Office version in VSTO 4 before this.Application is set

I would like to determine the version of Office/Excel in a VSTO Addin when CreateRibbonExtensibilityObject() is called on the Addin. I have encountered an issue with this, and have encountered: the this.Application of the addin is null, it is not…
Dan
  • 854
  • 8
  • 21