office-interop

How to raise an event on MS word Keypress

£可爱£侵袭症+ 提交于 2019-11-29 10:49:25
I am developing a MS-Word addon in which my code has to get access to the letters the user is entering through the keyboard. private void ThisDocument_Startup(object sender, System.EventArgs e) { this.SelectionChange += new SelectionEventHandler(ThisDocument_SelectionChange); } void ThisDocument_SelectionChange(object sender, SelectionEventArgs e) { MessageBox.Show(e.Selection.Text); } I think the SelectionChange event can give me the text but the event is not raised at keypress, Is there any way to trigger the event at keypress? Also if there is a more straightforward way to do it or an open

Why does systemprofile need Desktop folder to open excel file

二次信任 提交于 2019-11-29 10:42:20
We were unable to open an Excel Workbook with ASP.net before creating a folder named "Desktop" in the systemprofile Folder. The solution was to create a folder named "Desktop" in C:\Windows\SysWOW64\config\systemprofile\ Error Message: System.Runtime.InteropServices.COMException (0x800A03EC): Microsoft Office Excel cannot access the file 'c:\temp\test.xls'. There are several possible reasons: The file name or path does not exist. The file is being used by another program. The workbook you are trying to save has the same name as a currently open workbook. Does any one know an explanation for

Office Interop Does Not Work in Windows Service

最后都变了- 提交于 2019-11-29 09:53:19
问题 I have a very weird issue with Microsoft Office. I have a common library whose sole purpose is to open whatever word document file type is passed to it (by a full file path...) and save that opened word document as a pdf file. The weird issue is that if I consume that library from a windows service, whenever it attempts to open the word document, I get a null... aka, the word document never got opened. If however I consume the library from a WPF or Windows Form application I never have any

Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))

与世无争的帅哥 提交于 2019-11-29 08:20:06
I have a small C# Winforms Application that is using Word.Interop to Take a Single Mail Merge Document, copy each section, paste that section into it's own document, and save it individually. I keep (sometimes randomly) getting the error message: Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED)) . I have tested my below code and when I use breakpoints, I never receive this message. However, if I let it run uninhibited, it seems to error out at my line oNewWord.ActiveDocument.Range(0, 0).Paste(); . What is even weirder, sometimes I get the Exception Message

Word Automation Find and Replace not including Text Boxes

折月煮酒 提交于 2019-11-29 07:51:49
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 = objDoc.Content; object findtext = Field; object findreplacement = Value; object findwrap = WdFindWrap.wdFindContinue; object findreplace = WdReplace.wdReplaceAll; range.Find.Execute(findtext, missing, missing, missing, missing, missing, missing, findwrap, missing, findreplacement, findreplace); I suspect i need to change the range = objDoc.content

Inserting A Line Break (Not A Paragraph Break) Programatically To A Word Document

一个人想着一个人 提交于 2019-11-29 07:17:05
I am using the Office Developer Tools for Visual Studio 2013 in C#. Ever since Word 2007, adding a "\n" character adds a paragraph break (which adds more space than the line break in Word). How can I add a line break to a document? I've tried "\n", "\r", and "\r\n" all of which seem to add a paragraph break. user3731528 It turns out that Word uses Vertical Tabs for its line breaks. I was able to add them using the "\v" character to ranges. See What is a vertical tab? for more details. I've tried to use several items such as: </br> \n\r \u2028\n <w:br/> which they don't work but when simply

support different Office versions with Office Automation

老子叫甜甜 提交于 2019-11-29 06:56:31
问题 We created an application that uses Office 2007 (Excel 2007) to read in data from an Excel worksheet. However. I noticed that when I want to deploy the application on a system with Office 2003 installed, it crashes because other PIA's (and other dll's) need to be referenced for this version of office. Do I need to compile different versions of my application to be able to support different versions of Office or is there a more elegant solution for this problem? I use Visual Studio 2010 (C#)

Exporting the values in List to excel

穿精又带淫゛_ 提交于 2019-11-29 06:14:45
问题 Hi I am having a list container which contains the list of values. I wish to export the list values directly to Excel. Is there any way to do it directly? 回答1: OK, here is a step-by-step guide if you want to use COM. You have to have Excel installed. Add a reference to your project to the excel interop dll. To do this on the .NET tab select Microsoft.Office.Interop.Excel. There could be multiple assemblies with this name. Select the appropriate for your Visual Studio AND Excel version. Here

Office Interop with 64bit Windows in ASP.NET

守給你的承諾、 提交于 2019-11-29 05:23:11
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 user domain\username SID (S-X-X-XX-XXX-XXXX-XXX-XXXXX). This security permission can be modified using the Component Services administrative tool. Does anybody know what I need to change to get this working? Thanks if you can help. EDIT - This was working fine on a

Problems with office automation in asp.net. I can use alternatives such as open-office, if I knew how

余生长醉 提交于 2019-11-29 04:51:41
I have a ASP.NET 2.0 web application that should upload a ppt file and then extract its slides to images. For that I have imported office.dll and Microsoft.Office.Interop.PowerPoint.dll assemblies and wrote the following code public static int ExtractImages(string ppt, string targetPath, int width, int height) { var pptApplication = new ApplicationClass(); var pptPresentation = pptApplication.Presentations.Open(ppt, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse); var slides = new List<string>(); for (var i = 1; i <= pptPresentation.Slides.Count; i++) { var target = string