I have a WPF application that opens excel macros with the code
Process.Start("C:\\My Library\\MyFile.xlsm");
Now I want to run this sheet inside the WPF application. Is there any chance to open the excel sheet in a new WPF window, and run the macro?
Thanks for your help in advance.
It is not possible out of the box, to achieve such thing. You need to dig deep in msdn documentations about controls and libraries and how to reuse them.
So, I will suggest that you can use a third party "excel style" control.
You can check in this tutorial with a free tool - Spreadsheet Control.
Related
I'm new to WPF. I have a WPF application and I need to render an already existing excel file(section:-Batch Control Ticket). What I need to show in the WPF app is what exactly appears in the excel file. I know we can do it in a different way by loading the excel file in the C# code and mapping it in to a DataGrid. But it will not give the exact appearance of the file. I have seen some 3rd party availability but I need to purchase them and cannot be sure of their reliability. What can I do? Are there any tool available in WPF or a recommended other? The image shows how I need the app to appear.
I have written an Excel VSTO Addin with C# that is compatible with Excel 2013 as well as Excel 2016/365.
In Excel 2013, I see a tooltip window for every ribbon button, that contains my addin's name and a link to more information, which simply opens a help topic about addins.
I don't want either. If I add a "ScreenTip" or a "SuperTip" to my ribbon buttons, they will be added on top of this unwanted tooltip, but they don't replace it.
Excel 2016 does not show such tooltips.
How can I get rid of them? I only want my own ScreenTips and SuperTips
Since I am using the VS Ribbon designer, I have no, and don't want to have, access to the underlying ribbon XML.
You can't get rid of them, that part is controlled by Microsoft. Assumedly it was part of Microsoft's goal of helping to inform users that a control is not a Standard Office control, so that when it breaks, they don't blame MS for it, but instead recognize the identifier listed there and then seek support from whoever made the Add-In.
Short version: what is the preferred approach for embedding controls in a PowerPoint slide that send events back to an application-level add-in? The controls need to work in slide show mode and in design mode.
Long version:
I recently was brought into development on a legacy add-in for PowerPoint that (in a nutshell) pulls data from remote data sources and draws corresponding charts on slides. The add-in is managed code (C#), but is NOT built with VSTO - it uses custom wrappers and a COM shim.
The charts periodically need to be refreshed, and our add-in has a Refresh button in the toolbar for this purpose. In cases where a chart can't render at all until refreshed, we also embed a MSForms.CommandButton on the slide itself (as an OLE object). We have used this approach in a similar Excel add-in with success.
Unfortunately, it does not work in PowerPoint: the click event on the button does not seem to reach our add-in. I have found some information online that supports this observation. I have also tested it with a MSForms.ComboBox instead of a button and that worked--the combo box's change event reaches our add-in and the refresh succeeds.
So it seems that I need to find an alternative way to have the button communicate with our add-in. I can think of a few approaches and am wondering if there is a best practice:
Have the button (or a similar shape) run a macro that calls code in our add-in. I've heard that this might not work when the slide is viewed in Design Mode, but haven't tested yet to confirm.
Embed an MSForms form in the slide as well, to capture the click event and pass it on to our add-in. Again, this is just a theory and is untested as of yet.
Use something else entirely - something tells me there has to be a "modern" way of doing this, I'm just not familiar enough with Office development to know what that is.
I'll add that migrating to VSTO or a similar technology (such as NetOffice) is an option, but we'd prefer to avoid that if possible. Thanks!
I’m trying to show PDF files in Windows Form WebBrowser control. I do this by WebBrowser.Navigate() method. It is work when I want show one PDF file, which is not enough for me. I need when a user clicks a button , WebBrowser show another PDF file. What I have to do?
Avoid using WebBrowser control just to show a pdf. Try using one of the many free PDF libraries available for .net such as PDFSharp.
This will allow you to draw pdf's on to the Form and using TabControl you can create tabs programmatically and place a new pdf viewer inside of the tab.
You could easily make a 2 different files PDF viewer (side by side or top and bottom) by using the PDFSharp. Or you can use the ActiveX control for Adobe Reader.
Edit: It was my understanding that PDFSharp can render pdf's directly. This can only be done by exporting the page to a Jpeg/Png and then displaying the images. Sorry for any confusion.
At your place I'd do tabControl, and foreach tabControl, I'd put a webbroswer inwhich there would be a PDF by Tab.
EDIT : A WebBroswer isn't like internet explorer. Internet Explorer has the "Feature" of having multiple tabs (just like Chrome, etc). The WebBroswer Element is only the content of the tab :)
EDIT2 : After many years into this, I would recommend using a PDF library also. As a prototype usecase it might work, but in real world, we never know how many there will be. the best would probably to: either let the option to the user to open in a competent software i.e. Acrobat Reader where tab is natively used (DC), or use a PDF Library.
What i think is that you are facing a very simple navigate issue here. I have worked out a project for you, take a look at it, I hope it will solve your issue.
download here.
My scenario:
I have a requirement in my project(C#).I need to give the user only reading capability for my powerpoint presentation opened thru my application.All other featues like cut,copy,paste,save,saveas,print,right click context menus should be disabled.How can i achieve this in powerpoint programatically using c#? can anyone extend their help?
Can you publish the ppt as pps and use that file instead?
Just export each slide as a JPG or PNG and display those: Slide.Export. This would be for static slide views. If you want to retain animations, transitions, video/audio and navigation features for your PPT/PPTX, a PowerPoint-to-Flash converter is a better way to do this. iSpring makes a free version of their converter: www.ispringfree.com.
You should use the Powerpoint COM component, kind of like whats described here...
Using C# to display powerpoint
I have only used Word and Excel ones, and i must say they are extremely easy to use.
Or is you MUST make it completely read-only, id suggest writing your own ODF parser, or investigating in the ODF COM component, maybe that could work as well :)
One solution could be to use something like Aspose.Slides to render the Slides to TIFF or PDF and then display those inside your application.
If you have a low number of powerpoint presentations, you can look into Information Rights Management or use the Permissions Object. (Disclaimer:I have not used this)
Assuming that you're using Powerpoint Automation. Get hold of the PowerPoint.Application object and then loop through the CommandBars property and for each command bar, set Visible to false.
This should remove the command bars at least. And there might be other properties on the Application object that lets you disable context menus, but I've never really used powerpoint, so I'm not sure which ones.
I don't think that there's any good way of disabling printing etc altogether though. However, this MS KB article discusses a hacky way of dismissing any dialogs automatically, so assuming that the print/save etc would always bring up a dialog (which I'm not sure off) you might be able to use something from there: How To Dismiss a Dialog Box Displayed by an Office Application with Visual Basic
It's all VB code in that article, but the ideas will be similar.