how to interact with Silverlight VBA [duplicate] - vba

I have been using Excel VBA and WPF applications to scrape data from various websites, and all has gone well. But now I have run into something I cant get past.
The website is displaying its data within a Silverlight control:
<OBJECT width="100%" height=400 id=rnSilverlightGrid
data="data:application/x-oleobject;base64,QfXq3+...blah blah thousands of characters...AAAA=="
type=application/x-silverlight-2
</OBJECT>
(Left out what I thought was not helpful.)
getElementById("rnSilverlightGrid") returns nothing, but I am able to get a handle to the object with ie.document.all.tags("Object").Item(0), but have been unable to go further into the object to get data.
Can anyone tell me how now to get the data out of this Silverlight grid? This is currently coded in Excel VBA, but if necessary I can switch to WPF and use the WebBrowser control. I would rather not make the switch if avoidable (not sure how to do it there either anyways). I looked into White (seems like a dead end), and have seen other questions about this which have gone unanswered.
Thanks in advance!

Silverlight has the capability to make certain objects available to JavaScript calls so that JavaScript developers can affect the Silverlight application externally.
These are called "Scriptable Objects".
further reading: https://msdn.microsoft.com/en-us/library/cc645085(v=vs.95).aspx
My understanding is that this feature is available in SL4 and SL5.

Related

Getting Rid/Replacing ActiveX Functions

We are in the process of trying to make an old add-on that used ActiveX into a cross-browser solution (since currently only IE supports ActiveX). The only functions that are utilizing ActiveX are the <ComRegisterFunction()> and <ComUnregisterFunction()>. Is there a way to get rid of or replace these functions so that the application can be used on multiple browsers?
Also could someone explain what they do? I looked up what they were from microsoft itself, but I found it hard to understand what exactly was being registered.

XLA vs COM vs Automation vs Managed-Code Add-in

I need your help in deciding the best strategy and technology to choose from for the continuing development of a successful in-house VBA application.
In our company (a web-based distributor of financial information), over the years, we have developed a VBA XLA Add-in application for use only inside our company, which helps in the linking of our database of financial information with Excel worksheets, through the use of several UDF's, supported by ADO/SQL and other business objects logic. This app became a solid, fast, and useful tool for us, somewhat similar to old DDE links, but much more sophisticated and flexible than that.
Recently we replaced the ADO/SQL portion of the system with a SOAP based Web-Service and XMLHTTP MSXML 6.0 technology, literally putting our database into the cloud. The goal was to transform the application into a product which could be used outside of our company. That work is already done, and its behaving quite well, with all functionality, load at startup, user authentication and session control login/logout, seamless integration with EXCEL, user-friendly messages, all done in a single 2.036Kb XLA Add-In file, spanning more than 15.000 lines of good VBA code. However, we feel that it cannot yet be distributed like it is...
We feel that in order to be successfully published as a product to our clients, this application must be transformed into compiled code instead of the interpreted VBA. There are many reasons to justify doing that, including security, speed, robustness, etc.. but we don't need to go into these details right now.
Our fist thought was to use VB6 and Automation Designers to quickly transform our VBA code into a VB6 Automation Add-in. Apart from the fact that VB6 is old technology, it seems that Automation Add-in's are not the ideal solution, for our app requires some interaction with Excel events and the End-User, at least during the "login" and "logout" into the web-service based database (and some other functionality that requires user interaction through forms), BUT is seems that Automation Add-ins are not suitable to anything other than UDF's only. Here we would like to learn about other's experiences with Automation Add-ins and end-user interaction.
So, COM Add-in's are the next option. Again, these allow interaction through menu buttons and commands, but do not allow UDF's in the worksheets. Or so we've read. Also, we have read that COM Add-ins can be made as Automation Add-ins (allowing UDF's after all), but that they will work as two separate entities inside the Excel environment (one COM and one Add-In), one half not communicating with the other. That's not acceptable to us. Again, we'd like to learn more about other's experiences in that regard.
Then there is Managed Code (.NET, Interop, and VSTO) as other viable options. However, while simple to get started with, it is not clear that Interop came to stay, and it is not clear what is the best strategy with managed code. Again, we'd like to learn about other's experiences in this realm.
So, the questions final is: given our requirements (i.e., load at startup, access to data through SOAP based web-service (MSXML 6.0), UDF's functions, login/logout session control, user-friendly error handling, etc.), and the fact that we already have 15.000 lines of good VBA code, which is the best technology for us to continue to develop this Excel component, in order to make it into an easily and safely distributable product? All comments and thoughts in that regard are very welcome.
I would take a look at Excel DNA: https://github.com/Excel-DNA
I had a very similar problem developing a VBA add-in that communicates with an ASP.Net Web API. Couldn't really give all the code out in VBA, so we needed a way of giving out compiled code. Connecting to the web service was freezing up excel making it harder for users working with massive spreadsheets with multiple API calls.
You can develop them in visual studios easily using VB so a lot of the code could just be copied and pasted over then changed slightly to fit the later version of VB you're using.
Add-ins compile to .xll 64-bit and 32-bit versions.
We handle all login and connection to the API in the Ribbon: https://exceldna.codeplex.com/wikipage?title=Ribbon%20Customization&referringTitle=Documentation
And you can use newer VB forms which are more user-friendly.
Connect to other .dll files for sharing logic across multiple add-ins.
The UDF we use which call the API can all run asynchronously freeing up Excels main thread.
https://exceldna.codeplex.com/wikipage?title=Asynchronous%20Functions&referringTitle=Documentation
It can run any VBA specific or CAPI code by queuing as a macro.
Pretty much do everything that you could do in VBA plus more.
Govert the Developer https://stackoverflow.com/users/44264/govert is very active on StackOverflow and forums. He's helped us out loads in the development. And Excel DNA is still being updated and worked on.
Let me know if you want some more details.
great summary of your project.
I'm also curious what other thinks about the "right" solution for such task. It won't be an easy decision though.
My short answer will be "stick with VBA" unless you are really concerned about stealing your code from the great VBA add-in.
The reason I'd go for VBA is that the longer I've been working with VSTO/COM the better I've found VBA to be the best for handling tasks that are closely related to Excel (understand MS Office) object model. I'm saying that even I have written almost zero lines of VBA code in last 4 years. I do understand that you are using webservices and other dependencies but I'd say that if you have good progress and the add-in is working as expected I'd NOT throw myself to a completely new world of development (VSTO & C#) just to be cool, you will gain not too much value of this, especially if you know that
deploying managed code is harder that just copy your add-in to a
folder, set registry, done
troubleshooting is a way harder with managed code, basically you will have to log much more and trying to reproduce issues that may not happen in your environment but happens in clients
re-engineering of managed code is not such hard so if people really wants to steal your code they can do that unless you use obfuscation
and the last and probably the most important for you as much as I'm aware there is no easy way to do UDFs in VSTO
I have very minimal experience with VB6/ COM Automation so I'd love to hear opinion of guys who have done something similar before
Re: the VSTO & UDF, at my job, we have a VSTO add-in that somehow handles UDFs for a large project. I'm not the main developer of the application but I believe we use Excel DNA there so do check it to explore the managed code option further
Hope that helps

How to 'host' a Work Item inside a WinForms application?

I've come across a couple applications in the past that run outside VS2010 (or MTM) but display TFS Work Items 100% as they are shown in VS2010 as if there was a way to get the WorkItem including all its controls as a complete 'control' and place it inside my own application.
Does anyone know how to do that? I am currently trying to remember where I saw that, but maybe someone knows what I am talking about and can point me in the right direction TFS client api wise!?
Use the Microsoft.TeamFoundation.WorkItemTracking.Controls.WorkItemFormControl class. Doc on the MSDN.
This class has a property Item of type WorkItem, set the object and you're good to go.
If you want an application that uses it, I made this one, go get the sources, it's in the CegWICreator Project in the MainForm.cs file. If I remember correctly (the app is quite old) this control is pretty well used at some different places.

What is a good Silverlight resource for finding out what controls are available and what they're for?

I'm used to winforms development, haven't done any WPF and I'm starting a Silverlight project. I understand xaml and all (and I've got some resources for learning it) but I'm wondering if there's any resources available that shows what controls are used in what kinds of situations.
For instance, if you look at the BusinessApplication template in vs2010, they use a border or a grid in cases where I would think of a panel. Things like that.
I'm looking for more of a 'tips' kind of thing than a tutorial or reference. References normally just say what a control is; not when, where or why you would use a particular control.
These two should help you out...
http://samples.msdn.microsoft.com/Silverlight/SampleBrowser/#/?sref=HomePage
http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html

C++ DirectShow in Rendering Behavior

Does anyone know how to display DirectShow video in HTML container (e.h. DIV) instead of separate pop-up-like window.
Already I did all the things needed to run custom Rendering Behavior, it includes all interfaces and events handling, but cannot find anything related with my problem neither in the Internet nor in books I have.
Anyone can give me a hint what I need to do?
P.S.
MSDN articles mention only DirectDraw and Direct3D when setting IFlags on IHTMLPainter - but maybe it's a wrong place I'm looking for :-)
Regards.
In general, this is sort of a messy topic. As far as I know, your options are a custom activex control (yuck...in general, this approach is a logistical nightmare) or leveraging an existing player like Silverlight or Flash.
Silverlight doesn't give you control on a DirectShow level, but it does have additional support through the MediaStreamSource that may meet your needs. And once your audio/video is in Silverlight, you have all sorts of options for advanced overlays and interface elements.
I won't comment on Silverlight, as I have no experience of it, but I wouldn't agree with kidjan's summary of using an ActiveX control.
A custom ActiveX control has served our company well for many uses - including native apps, managed apps, web pages ...
The beauty of using an ActiveX control is that you have total control over the code in your player, stream authentication mechanisms, rendering capabilities etc.
I wrote an entire player in less than a month (network code included), then wrapped it in a COM control in less than a week.
Be under no illusion though, DirectShow and COM programming isn't easy. It's all about trade off - a Flash or Silverlight solution will probably get you going quickly. An ActiveX ctrl will give you total control.
I also read that HTML5 standard will include support for embedding video content(!) Might be worth looking into, although I don't know how many browsers support the (emerging) standard.