office-interop

How do I read the value of a checkbox in a word (*.doc) file in VB.net using a Range object?

How do I read the value of a checkbox in a word (*.doc) file in VB.net using a range object? This is what I have so far: Dim app As New Word.Application Dim doc As Document doc = app.Documents.Open("C:\myDoc.doc") dim chkBox as Bookmark chkBox = doc.Bookmarks("MyCheckbox") Dim rng as Range rng = chkBox.Range where "MyCheckbox" is the...

How to Instantiate ObjectFrame in VB.NET

I am trying to reach methods and properties of ObjectFrame through vb.net. But when I declared this as Dim objOLEObject As ObjectFrame and then trying to instantiate it as ObjOLEObject = New ObjectFrame it shows error like: "429: Retriveing the COM class factory for component with CLSID {3806e95d-e47c-11-cd-8701-00aa003f0f7} fai...

How it is correctly to implement IDTExtensibility2 interface for Office COM Add-In?

I am implementing COM Add-In for Outlook. I use IDTExtensibility2. I am not sure whether this is the best way of doing COM Add-Ins but I cannot change that. This interface defines five methods: OnConnection, OnStartupComplete, OnAddInsUpdate, OnBeginShutdown, OnDisconnection. I need to perform the following operations: Load configur...

Programmatically adjust font size to fit text inside a textbox in Word

One of my applications deals with MS Word and Document creation/editing/formatting. I am using Office 2007 w/ VS 2008, and i'm coding against the Microsoft.Office.Interop.Word library, which seems to work with either 2003 or 2008. I create a Textbox in a Document using the Document.Shapes.AddTextbox method, and then filling it with te...

Getting Error System.Runtime.InteropServices.COMException

Hey All, I am using Vb.Net to Create Labels in Microsoft. For that i am using below mantioend Code. Public Sub CreateLabel(ByVal StrFilter As String, ByVal Path As String) WordApp = CreateObject("Word.Application") ''Add a new document. WordDoc = WordApp.Documents.Add() Dim oConn As SqlConnection = New SqlConnection(con...

Determining MS Project Task Lineage

I have a MS Project file which I am using the Primary Interop Assemblies to parse. How can I determine the lineage of a task? I was relying on the WBS code, however the client has started to fiddle with this field and it no longer represents the hierarchy of the data. Edit: By lineage I mean a way to identify where in the hierarchy the...

.NET/COM Interop problem - opening Outlook 2003 Send Mail dialog

We have a WinForms app, written in VB.NET (CLR 2.0), that does a lot of Outlook-related stuff. One of the things we do is programmatically open up a new Outlook 2003 'compose new Email' form, pre-populated with the 'to' address. Me.WordApp = New Word.Application Dim template As Object = System.Reflection.Missing.Value Dim newTemplate A...

Setting a cell's format using Excel 2007 Interop and C#

I'm using the office 2007 interop assemblies to create some excel spreadsheets. There are plenty of questions on here about getting started and MSDN contains heaps of articles, like this one. The API is funky, and sometimes a bit confusing. When I set a value of a cell, is there a way to set it's format? I'd like to mark particular f...

Best way to extract data from Microsoft Word

The release notes of a software have some important data that I would like to extract in every release. Is there a way to extract certain information from Microsoft Word? The application that I am thinking of would be written in C#, but I am okay if it is any other solution. ...

Help using the Office Interop for Word and Outlook 2007 in VB.NET

I need to start utilizing the interop in my programs to automate several functions in Word and Outlook and I was checking if anyone knew a good place to start. My ultimate goal is for my program to kick off a mail merge, create several different files and save them accordingly, then e-mail the different files to different people based u...

Capturing Word document filenames through automation through C#

I am using word to generate letters for my application. However, I would like to capture the filename and location that the user has saved to and send/pass this filename and location back to my application. Idea is that my application has a record of the files that have been created, so the user can click on the file name and word start...

Office Interop with 64bit Windows in ASP.NET

I'm trying to do office 2003 interop using C# ASP.NET on a server running Windows 2003 64 bit (I'm running IIS in 32bit mode though) and getting error messages like: The machine-default permission settings do not grant Local Activation permission for the COM Server application with CLSID {00024500-0000-0000-C000-000000000046} to the us...

Export DataTables into multiple Excel worksheets

I've got a load of DataTables that I want to export into several Excel worksheets (in a new spreadsheet / Excel file). The "solution" that already exists in the code I have is two nested for loops, iterating over all the rows and columns, inserting data cell-by-cell. This isn't ideal as the process takes well over 10 minutes. There's a f...

Excel & WPF modal form

I've got this situation. (.net 3.5) A Winform application that with OleAutomation and Office Interop create an excel, a toolbar and handlers for buttons in the toolbar. Now we've got some functionality that shows the user modal windows (winform 2.0) with the method: form.ShowDialog(new ExcelHwndWrapper(objExcelApplication.HWND)) And...

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 this code to create a new application: Microsoft.Office.Interop.Excel app = new Mic...

Is it possible to insert a PDF into a Word mail merge using C#.

I need to print one or more PDF brochures with each letter in a Word mail merge (based on the value of a field in the source query from SQL Server). Is this possible? Or is there another way of achieving this? ...

Excel 2007 is locked when used as a datasource for Word Mail Merge

When using Word 2007 MailMerge with an Excel 2007 (xlsx) as a datasource, the .XLSX file is locked and cannot even be copied using Windows Explorer. It is possible to connect to the Excel file as a datasource (using Visual Studio 2008 and .NET 3.5) but it is not possible to use the Office automation or similar third party components. We...

C#: How can I open and close an Excel workbook?

Does anyone know how to simply open and close an Excel workbook? I don't need to read any data from the file, I just need to open and close it. (*) I'm guessing that I'll need to reference the Microsoft.Office.Interop.Excel assembly. *Reason: I've already configured pivot table information with a 3rd party library (Aspose). Now I ne...

How to replace a section in a word template with multiple fields C#

Hi I'm creating a C# application that fills the MergeFields defined on a MS Word document with data from an external Data Source. I'm using the OpenXml SDK and everything works fine when replacing single fields. What I want to do is, to have a section with several MergeFields defined and being able to copy such section several times a...

Detecting and dynamicly loading the installed Microsoft Word Object Library

A little back story: I have small application that will use Word to generate a Outlook signature based on a Word template and data from the company active directory. It works wonderful on computers with Office 2007, since I used "Microsoft Word 12.0 Object Library" when I coded it on my own computer. There are quite a few computers on t...