office-interop

Multiple heading styles using the same multilevel list style

五迷三道 提交于 2019-12-11 12:45:00
问题 I'm trying to assign numbering to multiple heading styles in Word, so that I get content like the following: 6. <Heading 1> 6.1. <Heading 2> 6.1.1. <Heading 3> 6.2. <Heading 2> 6.2.1. <Heading 3> 6.3. <Heading 2> You can do this pretty easily in standard Word by using the second multilevel numbering style (ignoring 'None'), the one that looks like this: 1. 1.1. 1.1.1. But I'm trying to do this dynamically, by applying the second multilevel numbering style in code, and it comes out like this:

Get previous MailItem when reply on outlook

穿精又带淫゛_ 提交于 2019-12-11 11:53:12
问题 We are developer an outlook plugin. We provide an button work as alternative of default Send button. We need save all MailItem replied by our button to a specific category. When user reply an email (in new inspector), how can I get the main MailItem be replied ? 回答1: A user can reply from either Explorer or Inspector. In case of Explorer, trap the Explorer.SelectionChange event and set up event sinks on the selected items. You can trap the MailItem.Reply/ReplyAll/Forward events. In case of

How can I programmatically create an Excel “sort/Filter combobox”?

折月煮酒 提交于 2019-12-11 10:29:10
问题 I'm reverse-engineering a manually created spreadsheet for dynamic creation. Most of the cells are populated with simple data, but there are a couple that are "sort/Filter" dropdowns like so: How can I dynamically create such a control? Is there a way to "view source" in the Excel spreadsheet to see what sort of code might be required to produce these controls? UPDATE Adapting MacroMark's code, this compiles: var rangeMonthYears = _xlSheet.Range[_xlSheet.Cells[7, 3], _xlSheet.Cells[7, 15]];

How to Create listener Outlook.ItemsEvents_ItemAddEventHandler for every mail folder?

谁说胖子不能爱 提交于 2019-12-11 10:18:28
问题 I can listen on default folder like this: _outlookNameSpace = this.Application.GetNamespace("MAPI"); _inbox = _outlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox); _items = _inbox.Items; _items.ItemAdd += new Outlook.ItemsEvents_ItemAddEventHandler(items_ItemAdd); How can I add a listener on all folders and sub folders ? Or listen for all incoming mail before it is placed in a folder or subfolder ? 回答1: You need to store Items objects in a list

VB.net Office Solution - Accessing value in named Range in a Worksheet

江枫思渺然 提交于 2019-12-11 09:53:25
问题 I'm working on converting an Excel VBA project to a VB.net Office Solution. In VBA accessing a named range within a sheet was pretty easy. Sheet1.Range("NamedRange") would give you the value in that cell. In VB.net I've tried several different things, all ending in failure. I started here. http://msdn.microsoft.com/en-us/library/aa168292(v=office.11).aspx#excelobj_link9 I'm using one of the Visual Studio Excel 2010 Document template, and I managed to set a value in a named range on a sheet.

How to overcome custom document property size limit

♀尐吖头ヾ 提交于 2019-12-11 09:29:14
问题 I need to save long (,document specific) string to an Excel document. Since the length limit for Office.Core.CustomDocumentProperty.value is only 255 char, please advise on how to overcome this limit, or suggesting other ways to store data in an Excel document. (To my recollection, a cell formula can only store 255 char, so this is not a workable solution.) 回答1: Just split your value into multiple properties. Something like this would work. private static void WriteCustomDocumentProperty

Adding content control throws an exception dynamically

六眼飞鱼酱① 提交于 2019-12-11 08:30:36
问题 I am fairly new to Word Addin development. Fortunately I was able to do almost everything but stuck at some simple issue I belive. I want to insert plain text controls dynamically at the selected range. For this I am using the following: currentDocument = application.ActiveDocument; foreach(var field in myFieldsList) { Microsoft.Office.Interop.Word.Range rng = currentDocument.ActiveWindow.Selection.Range; object oRng = rng; var contentControlPlain = application.ActiveDocument.ContentControls

Excel VSTO Add-In: Cannot reactivate Excel after MessageBox.Show(“Test”);

不问归期 提交于 2019-12-11 08:07:00
问题 I am implementing a VSTO Excel Add-In which displays some modal dialogs. These dialogs are not shown as own windows in the windows taskbar. But under certain circumstances these dialogs are not are vanishing from the top of Excel and cannot got back by using the task bar! The whole story (reproducable with Windows XP - 7, Excel 2007 - 2010): I do open Excel and create two or more new workbooks I do show a modal dialog, let's say via "MessageBox.Show" I open "notepad" and maximize its window I

How to read the hyper-link of an image in power Point using c#

為{幸葍}努か 提交于 2019-12-11 07:57:52
问题 I have inserted an image to powerpoint using c# and have inserted a hyperlink to the picture and its working perfectly.But now i need to read the hyperlink of that picture which i have inserted using c#. Whereas am inserting a text with hyperlink into powerpoint using c# ,and am reading the hyperlink back from the powerpoint by the below method. for (int i = 0; i < presentation.Slides.Count; i++) { foreach (var item in presentation.Slides[i + 1].Shapes) { var shape = (PPT.Shape)item; if

How to copy html text selection and assign it to a string in c#

佐手、 提交于 2019-12-11 07:44:50
问题 I have an .html file containing only text(formatted somehow).I am wondering if there is a way to copy all of the text(like if would do with ctrl+A) and assign it to a string So I can then export it to .txt file ? All this must happen from the code-behind(opening the html, selecting the text and assigning it to a string). In the Microsoft.Office.Interop I remember that there was an option for copying the active window selection or something, so I was wondering if this is possible and here. 回答1