office-interop

Create Excel files from C# without office

Possible Duplicate: Create Excel (.XLS and .XLSX) file from C# I am writing a program that generates excel reports, currently using the Microsoft.Interop.Excel reference. My dev computer has Excel on it, but the end user may or may not have Office installed. Will this tool fail if Office isn't installed on the end users comp...

Slow performance when utilizing Interop.DSOFile to search files by Custom Document Property

I am new to the world of VB.NET and have been tasked to put together a little program to search a directory of about 2000 Excel spreadsheets and put together a list to display based on the value of a Custom Document Property within that spreadsheet file. Given that I am far from a computer programmer by education or trade, this has been ...

How to detect if a doc document password protected

Hello. I have a folder with lots of doc-documents and I need to upload their context into database. The problem is that some of them are password protected and I don't know the password. I would like to skip them but I don't know how to detect if password protection presents. If someone helps I'll appriciate it greatly. P.S. Programmi...

Office Add-in to execute on save

I'm developing an Office 2007 add-in. I would like to have a piece of code execute whenever the user Saves a document. I'm principally interested in Word, Excel and PowerPoint, but I'd prefer to also support other Office apps (such as Visio and Microsoft Project). Looking for either a code sample, or a link to an article that describe...

Outlook 2010 Retrieving and restricting appointments programmatically causing recurrences to be included

I wrote a winforms app that uses Microsoft.Office.Interop.Outlook to retrieve and restrict appointments based upon the date range entered by a user. This worked fine with Outlook 2007 installed, however now that some users have updated to Outlook 2010 the appointment retrieval is pulling back incorrect appointments along with the corr...

System.AccessViolationException: Attempted to read or write protected memory.

I get the following exception when I try to "find and replace" in a Word 2007 working on Windows Vista or Windows 7. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at Microsoft.Office.Interop.Word.Find.Execute(Object& FindText, Objec...

"No printers are installed." problem when using excel 2003 interop sheet.PageSetup through a WCF service

We have a WCF service that generates an Excel file off of a template and feeds it back to the client in a byte array. For some reason, we are getting an error when we try to do this: sheet.PageSetup.CenterHeader = sheet.PageSetup.CenterHeader.Replace("[customerName]", customerName).Replace("[dateTime]", date.ToShortDateString()); When...

What's currently the best way to extend Excel using C#?

I have the professional versions of VS2008 & VS2010. I wish to add a couple buttons to a toolbar in Excel. When they are clicked I'd like to be able to open a form (either WinForms or WPF is fine) collect a few values from the user in the form and then take that data + read cell values from the current worksheet to perform some databas...

Outlook VSTO AddIn Configuration

I'm working on VSTO addin for outlook 2003.Outlook can read the startup section from Outlook.exe.config. <startup> <supportedRuntime version="v1.0.3705" /> <supportedRuntime version="v1.1.4322" /> <supportedRuntime version="v2.0.50727" /> </startup> But it is not able to read the system.diagnostics section of the confi...

Create word document and add image from .NET app

I need a way of generating a word document (from a template or something) and inserting an image at a specific place. Does anyone have any pointers on the best way to do this? I worked on a project that used Office Automation in .NET 1.1 a few years ago, and it was really unspeakably poor. I'm assuming OA has either been improved or bee...

Open the Word Application from a button on a web page

I'm developing a proof of concept web application: A web page with a button that opens the Word Application installed on the user's PC. I'm stuck with a C# project in Visual Studio 2008 Express (Windows XP client, LAMP server). I've followed the Writing an ActiveX Control in .NET tutorial and after some tuning it worked fine. Then I add...

What is the most elegant solution for generating PowerPoint slides online?

I would like some advice on the following please. We have an ASP.net site where we need to generate PowerPoint slides of the data. The slides will need to include charts and tables. I have come across Aspose.Slides online which seems a good option Is this the best solution for this? What are your experiences with Aspose.Slides? Are th...

How to check whether a excel file is write protected or not in C#?

Hi, I'm developing a sample application in which I have to open an excel file and check whether the file is write protected or not. The code is using System.Windows.Forms; using Microsoft.Office.Core; private void button1_Click(object sender, EventArgs e) { string fileNameAndPath = @"D:\Sample\Sample1.xls"; // the above exc...

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., <DATE> needs to be replaced with DateTime.Now.Format("MM/dd/yyyy"). The find/replace works fine. However, s...

ERROR! (Using Excel's named ranges from C#)

In the following, I am trying to persist a set of objects in an excel worksheet. Each time the function is called to store a value, it should allocate the next cell of the A column to store that object. However, an exception is thrown by the Interop library on the first call to get_Range(). (right after the catch block) Does anyone kn...

How do you place an Excel Sheet/Workbook onto a C# .NET Winform?

I am trying to create a stand alone application in Visual Studio 2008 C# .Net that will house Excel Workbooks (2007). I am using Office.Interop in order to create the Excel application and I open the workbooks via Workbooks.Open(...). The Interop does not provide any functionality to "move" the workbooks onto a form so I turned to P/I...

How do you replicate changes from one excel sheet to another in two separate excel apps?

This is all in C# .NET Excel Interop Automation for Office 2007. Say you create two excel apps and open the same workbook for each application: app = new Excel.ApplicationClass(); app2 = new Excel.ApplicationClass(); string fileLocation = "myBook.xslx"; workbook = app.Workbooks.Open(fileLocation, Type.Missing, Type.Missin...

Error While using Excel Interop's set_Value(XLRangeValueDataType.XLRangeValueMSPersistXML,object)

Hi, I am getting error while using the Excel Interops set_Value on a range. Any help/suggestion will be valuable. This is the code which is failing. using Excel = Microsoft.Office.Interop.Excel; Excel.Application xlApp = new Excel.ApplicationClass(); Excel.WorkBook WB = xlApp.Workbooks.Add(Type.Missing); Excel.WorkSheet WS = WB.Sheets...

Determine Excel Version/Culture via Microsoft.Office.Interop.Excel

How can I achieve that in .NET/C#? ...

How to obtain PowerPoint File Format Programmatically

I need to determine whether the ActivePresentation is 97-2003 or 2007 format. I really won't want to check the extension. Is there a property somewhere inside the PowerPoint Object Model which gives this info? ...