office-interop

Detecing password protected PPT and XLS documents

痴心易碎 提交于 2019-12-05 15:38:11
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 (bytes.Skip(0x214).Take(1).ToArray()[0] == 0x2f) return true; //XLS 2005 if (bytes.Skip(0x20B).Take(1).ToArray()[0] == 0x13) return true; //DOC 2005 However it does not seem to cover all XLS files and I am also looking for a way to detect PPT files in the same manner. Does anyway know which bytes to look at for these file types? I saved a PowerPoint

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

非 Y 不嫁゛ 提交于 2019-12-05 15:02:41
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 configuration data from file Load registry data Start new session Create *.pst file Subscribe to Explorer events Connect to Internet Server to get some data Create menu items in the main menu Create a toolbar Add/Remove several things in Outllok (on *.pst files level)

The Microsoft.Office.Interop.Word assembly version is higher than referenced

烈酒焚心 提交于 2019-12-05 11:33:26
What is the cause of the following error: Error 12 Assembly 'Microsoft.Office.Interop.Word, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' uses 'office, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' which has a higher version than referenced assembly 'office, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' c:\Program Files\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\Office14\Microsoft.Office.Interop.Word.dll WindowsFormsApplication1 my code : using System; using System.Collections.Generic; using System

Problem closing excel interop app properly in .net

橙三吉。 提交于 2019-12-05 10:20:49
I am having issues using interop with office excel in .net. I have tried a lot of things to close the excel application, workbook and worksheets i create to use in my program but i always notice the excel.exe still in memory. I have even tried forcing the garbage collector, please help. Here is the code i use to instantiate everything: Private mExcelApp As Microsoft.Office.Interop.Excel.ApplicationClass Private mWorkBook As Microsoft.Office.Interop.Excel.Workbook Private mWorkSheet As Microsoft.Office.Interop.Excel.Worksheet Public Sub Execute() mExcelApp = New Microsoft.Office.Interop.Excel

Changing font (Trebuchet MS, Calibari) in Excel programmatically C#

霸气de小男生 提交于 2019-12-05 09:43:01
I am currently working in a C# application which has a class which will generate an excel file. Everything went smooth. The data populated on the excel sheet has 'Times New Roman' has font. I would like to change it to some other fonts (Calibari). How can I do that programmatically. Here is how: //Declare Excel Interop variables Microsoft.Office.Interop.Excel.Application xlApp; Microsoft.Office.Interop.Excel.Workbook xlWorkBook; Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet; //Initialize variables xlApp = new Microsoft.Office.Interop.Excel.ApplicationClass(); xlWorkBook = xlApp

Can Microsoft.office.interop.word.dll work without installing office?

北城余情 提交于 2019-12-05 09:09:04
My ASP.Net-C# application works with mailmerge and the dll by name Microsoft.Office.Interop.Word.dll V14.0.0.0. All is well on my desktop (where office is installed). However when this application is deployed on the production machine, the following error is thrown: System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). When the class is registered, the following error is

How to read MS Word paragraph and table content line by line

会有一股神秘感。 提交于 2019-12-05 06:30:31
问题 I am reading word document in C# (3.5) using Microsoft.Office.Interop.Word . Reading line by line, splitting line into array[] and processing every word of line and based on some business logic replacing some words and after the replacement of words, replacing the complete line with converted line. Till now Every thing is working fine. Now i have some word documents, those are having paragraph and tables. I want to read every Column of the table one by one and replace the content of the

C# Outlook 2007 COM interop application does not exit!

怎甘沉沦 提交于 2019-12-05 06:03:38
Any ideas why the following code does not exit the Outlook 2007 process created via COM interop? Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application(); var item = app.Session.OpenSharedItem("C:\\test.msg") as Microsoft.Office.Interop.Outlook.MailItem; string body = item.HTMLBody; int att = item.Attachments.Count; (item as Microsoft.Office.Interop.Outlook._MailItem).Close(Microsoft.Office.Interop.Outlook.OlInspectorClose.olDiscard); System.Runtime.InteropServices.Marshal.ReleaseComObject(item); (app as Microsoft.Office.Interop.Outlook._Application

using c# to select a worksheet in excel

久未见 提交于 2019-12-05 05:20:41
Using C# in .NET 3.5 with Visual Studio 2008, I am trying to set focus (or activate) a specific worksheet in an open workbook: Here are some properties: public Excel.Application xlApp {get;set;} public Excel.Workbook xlWorkBook { get; set; } public Excel.Worksheet xlWorkSheet { get; set; } public Excel.Range range { get; set; } And here is how I am trying to select a specific worksheet: (xlWorkSheet)Application.ActiveWorkbook.Sheets[FormControls.WorksheetFocus]).Select(Type.Missing); And I have also tried this way: ((Excel.Worksheet)this.Application.ActiveWorkbook.Sheets[1]).Select(); What am

OneNote 2013 Add-in won't load. How to debug?

风格不统一 提交于 2019-12-05 04:56:46
问题 I'm following the excellent tutorial by Malte Ahrens on how to create a OneNote add-in. Initially I followed it step by step, making a few changes (just renaming the class, and using my own name and GUID in the assembly) info. As I'm using VS2012 and am not yet ready to hand-roll a WiX installer I manually copied over the built dll to the correct place and also created a registry file to make the requisite entries. I confirmed that they were all there, loaded up OneNote but no add-in, going