office-interop

Primitive MailMerge using just delimited field names

Obviously the correct way for our app to generate a Word document based on a template is to encourage the admin users (who will look after the templates) to embed the correct merge fields or bookmarks in the template document. However in the past we have found our typical admin user who ordinarily doesn't use MailMerge or any of the oth...

How can I determine the table cell the bookmark belongs to using Office.Interop

Okay, I am creating an application in C#. That application needs to create a MS Word document out of the template. That template contains a table and a bookmark stored in one of the table's cells. I need to reference that cell, i.e. I need to determine it's row and column. Thanks for all the help. ...

How to disable security pop ups of MS Outlook in C#?

How to disable security pop ups of MS Outlook using C#? I am getting the security pop up, while trying to initiate outlook task to be created using my c# application. (Using Microsoft Office Outlook 11.0 Object Library)) Screen would looks like Thanks ...

How to programmatically rename an Outlook 2007 item attachment?

How do i programmatically change the filename of an Outlook item attachment. Ideally I'd like it to be something like this: Outlook.DocumentItem d; foreach (object ob in oFolder.Items) { d=(Outlook.DocumentItem)ob; d.Attachments[1].FileName = "xyz.pdf"; } Please ignore assumption about there being an attachment, Im only interested...

C#: Create/Insert Excel 2007 charts into Word 2007

How do you create and then insert an Excel 2007 chart in Word 2007 with office interoperability? Important: I do not want to save an Excel file to create a chart. ...

Error with Excel Automation/Office Interop for Microsoft.Office.Interop.Excel.WorkbookClass.ResetColors()

I've written an application that converts 1000s of Excel documents into PDFs (I know this is a slow method, but I'm not worried about speed), using the same technique as this, but for Excel instead of Word. I had the requirement to add the following code: book.ResetColors(); This is on the Workbook object. For the majority of cases t...

MS Powerpoint Automation with Reflection

I need to save powerpoints as HTML with c#. I also need to turn on animations with the 'ShowSlideAnimation' property. The first code block works fine, but when I duplicate the code with reflection, I am unable to get the 'WebOptions' property because it is null. I chose to do this without referencing the office assemblies because some...

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 Outlook folders to a PST using .Net? [vb or c# no matter] ...

Invisibly marking up text in a word document

I wan't to build a word 2007 add-in that allows users to: Hilight pargraphs etc. of text in a word document. Click a toolbar button or select an option from a right-click menu to "mark" the text as being some type of data (there will be 3 of 4 different types of data) Also, the ability to select some text and and unmark it (this would ...

How to import Microsoft Office constants (msoTrue, ppLayoutText...) into LotusScript?

I am trying to programmatically make a PowerPoint presentation from the contents of a Lotus Notes document. This is relatively straight-forward using CreateObject("Powerpoint.Application") but I fail to find a way to access the various constants that are used in VBA. One solution is of course to hard-code the (ten or so) values into my...

Word MailMerge automation - Find out the data source's encoding

I have a Word add-in I wrote using .NET. The add-in basically processes a Word document which is configured for MailMerge and extracts the data from the data source. I need to know which encoding Word uses to access that data source. When I use a datasource (CSV for example) that is not encoded with my default system locale, Word alerts...

Word 2007 ContentControl.SetPlaceholderText maximum string size

I am planning to set the text in a content control, by using the Word.ContentControl.SetPlaceholderText() method: string myText = "Hello World!"; Word.ContentControl ctrl; ctrl.SetPlaceholderText((null, null, myText); myText = ctrl.PlaceholderText.Value; Can somebody let me know if there is any size limitation on the myText string? ...

Get email folder from MailItem via MAPI interface

I'm creating a program to automatically generate reports from incoming email attachments and it is almost complete save for one area. The incoming emails are automatically filtered into folders which differentiate which client and server they originate from. I can't figure out how to get the path of the folder from the email Item. I'm u...

Compiling applications using MS Office Interop assemblies

I need to build a C#-application that uses the Excel interop assemblies on a dedicated build-computer. Is there any way to do that without installing MS Office on the build-box? ...

How to speed up generation of Word files from C#?

Hi, I'm working on an application that generates a relatively large amount of Word output. Currently, we're using Word Interop services to do the document creation, but it's quite slow, especially in older (pre-2007) versions of Office. We'd like to speed up the generation. I haven't done a lot of profiling yet, but I'm pretty confiden...

Excel file with multiple sheets from SSRS Reports

Hi, Let's say i have 3 byte arrays, each representin a .xls file. How can i combine them into a single xls file with 3 sheets. The SSRS reports are very rich and include charts sp oledb is not an option. Performance is not important so i could save them to disk if needed, as a last resort i could even use an excel macro (if i knew how ...

Excel replace value without losing formatting

I got an application that automates Microsoft Excel (2003) using Office Automation. One of the things it does is replacing values. The problem I got is that when replacing values, all rich formatting is lost as explained here: http://support.microsoft.com/kb/177194 To clarify, I replace valueX with valueY in a cell looking like this: va...

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 tasks is around 5-10x slower using dynamic than the "old" way. Has anyone else experienced...

Error - Index refers beyond end of list

Problem saving file back to SharePoint with Excel COM lib. I open the file but it opens as 'xlviewer.xlsx' so I assume I need to overwrite the original file. (I removed the try/catch to do some error handling.) When I do I get this error: "Index refers beyond end of list" (error at line: 42 'SaveAs statement') using System; using Syst...

Is it possible to request temporary trusted access to VBA project object model?

I need to access the VBA code of Office documents (Excel workbooks, but it's not relevant) through .Net / C#. I know how to do this, but this requires the Office user to have granted trusted access to the VBA project object model through the Office app. This makes me uncomfortable, because there is a risk that the user leaves things set ...