vsto

VSTO: Application Focus

非 Y 不嫁゛ 提交于 2019-12-05 08:00:56
Anyone know of a way to see if the Excel window of a VSTO project is active/in focus? I'm looking for an equivalent of System.Windows.Window.IsActive . I've been frustrated with this as well. Are you using a dialog in the VSTO app? If so, what I have done is add an event to the closing of a Windows Form/Dialog to activate the Office application as follows (example is with Word, so there may be differences in Excel): //... VSTO Startup Event WindowsForm form = new WindowsForm(); form.FormClosed += new FormClosedEventHandler(form_FormClosed); form.Show(); void form_FormClosed(object sender,

Opening a saved workbook causes the current workbook to throw exceptions

爱⌒轻易说出口 提交于 2019-12-05 06:47:09
I'm trying to open a save Excel workbook while keeping a reference to the current workbook. The issue is that as soon as I open the saved workbook, the original throws an exception upon access. Here's a code snippet to demonstrate. I put this in an event handler for a ribbon button to test it. try { string workbookPath = @"C:\Temp\Test.xlsx"; Workbook current = Globals.ThisAddIn.Application.ActiveWorkbook; Workbook newWorkbook = Globals.ThisAddIn.Application.Workbooks.Open(workbookPath); current.Activate(); // throws an exception Sheets sheets = current.Worksheets; // throws an exception

Add controls to existing ribbon group in Office (VSTO)

最后都变了- 提交于 2019-12-05 06:25:26
I find numerous examples on how to add a new group to an existing ribbon, and this works just fine. What I cannot figure out is how I can add new controls to an existing group on an existing ribbon. Say I want to add my own command to the "Proofing" group on the "Review" tab. I'm developing this in VS2010 for Office2010, but I guess the same approach would work on Office 2007 as well. Any pointers or help is appreciated, or if it's not possible to do (without too much hacking) I can live with that as well. Unfortunately, this is not possible. You may only add controls to custom groups in

Is there a way to capture HotKeys/Shortcuts in Excel VSTO using only C# and no VBA?

删除回忆录丶 提交于 2019-12-05 04:37:07
So I want to capture some key-commands in our Docuement-level Excel VSTO addin. I can't seem to find a way to do it, other than to use VBA and have our addin talk to the VBA. Any help/examples would be greatly appreciated. I am using Excel 2007. You can only do this through API calls to subclass Excel and watch for key commands. This is older, but it still applies. Anonymous Type One method involves using the 3rd party solution from Addin-Express . Their product includes the ability to add a keyboard shortcut as a property to the ribbon menu commands. The other way is to make use of low level

How to center a WPF Window in a Excel VSTO addin

别等时光非礼了梦想. 提交于 2019-12-05 04:32:38
The problem is that a WPF window only takes a system.form.window so I cannot set Excel to be the owner object in my VSTO application, because the VSTO addin only exposes Excel's hwnd, or its active window as a Native Window since it is COM. That means when WindowStartUpLoadation is set to be center owner it doesn't work. So I am forced to work around this. What I have come up with so far after reading this site is to try and manually center the window, but even with his simple example my window never appears centered. private static void CenterWpfWindowInExcel(WpfParameterDialog wpfDialog) {

first blank row in excel

a 夏天 提交于 2019-12-05 04:15:48
Is there a way to find first available blank row in excel sheet using vsto or c# ? I have been searching for hours but cant find any thing related to it. Any help in this regard will be greatly appreciated If App is your excel application, you can loop throught the rows starting from number 1 and look for the first empty using CountA function (it returns the number of non empty cells for a Range): int rowIdx = 0; int notEmpty = 1; while (notEmpty > 0) { string aCellAddress = "A" + (++rowIdx).ToString(); Range row = App.get_Range(aCellAddress, aCellAddress).EntireRow; notEmpty = _App

How can I add the images to button using the ribbon xml?

泄露秘密 提交于 2019-12-05 03:47:20
How to add the custom images to the ribbon button in the tab and the context menu. I tried the link Adding Image to ribbon button but no luck :-(. I am designing the addin for Excel. I added this in the header. <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load" loadImage="Ribbon_LoadImage"> <button id="btn2d" keytip="L" screentip="2D Visualization" supertip="2D Part Visualization" label="2D" size="large"/> <contextMenu idMso="ContextMenuCell"> <button id="btn1" label="my label"/> </customUI> the code snippet public Bitmap Ribbon_LoadImage(IRibbonControl

Install VSTO WITHOUT using Clickonce

霸气de小男生 提交于 2019-12-05 03:42:14
I just created my first VSTO Add-In for Excel. I'm trying to find a way to install the add-in on the end users machine easily. If I copy the the .dll and try to add it from the COM Add-Ins manager in Excel I get this error: <ProjectName>.dll is not a valid Office Add-in. If I use the publish wizard, it does not give me an option to select where to install the files on the client PC. Instead, it uses the path to the installation files. So, how can I install my VSTO add-in without using the publish wizard (AKA clickonce)? You should be using Visual Studio Setup Project and add your vsto project

Catch mouse events in PowerPoint designer through VSTO

穿精又带淫゛_ 提交于 2019-12-05 02:16:46
问题 I am developing an add-in for PowerPoint (2013) with C# / VSTO. The add-in will work when the user is in design mode, not presentation mode . How can I catch mouse events with regard to shapes/objects on the slides, e.g. mouseOver, mouseDown etc? I want to listen to these events in order to create custom UI located near the objects / shapes. Are there any events I can listen to, or is it necessary to use more advanced methods, such as creating a global mouse listener, translate the

Paste Special in C# vsto Excel

做~自己de王妃 提交于 2019-12-05 02:10:29
问题 I am working on the C# vsto Excel application. Whenever user pastes something in the excel template from another excel sheet,it also pastes Cell format along with the cell data in the excel template. I want to avoid this. So i googled & i came across term paste special. Paste special will only paste the contents and will no alter the format of the current sheet. I want to introduce paste special option in my vsto application. I have code here, Application.OnKey("^v", "PasteSpecV"); but its