This isn’t true API access, just a WebBrowser control. I’m looking into the API though which would require me to register my Application even though it’s not a Windows App.
It has a launcher (I haven’t decided exactly how I’ll integrate this) that will launch the Microsoft Office Online services at the click of a button.
As you can see, you can still access the Navigation provided by Microsoft. I fixed the Winform so it doesn’t launch a new window and keeps everything inside the Winform on the WebBrowser control.
I guess I see this side project being useful for someone who wants to use the free Office.com Online services with their Microsoft account and don’t want the full browser experience.
Some notes to get this to render properly in the WebBrowser control.
I had to force a User Agent to indicate I was using IE11. I think what I was seeing was that the WebBrowser control was defaulting to MSIE7. Made things look like crap.
VB.NET Code for this:
Private Property uag As String = "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko" _ Private Shared Function UrlMkSetSessionOption(ByVal dwOption As Integer, ByVal pBuffer As String, ByVal dwBufferLength As Integer, ByVal dwReserved As Integer) As Integer End Function Const URLMON_OPTION_USERAGENT As Integer = &H10000001 Public Function ChangeUserAgent(ByVal Agent As String) UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, Agent, Agent.Length, 0) End Function
I implemented forcing new windows to the WebBrowser control in the Winform. If you use the top navigation at all, it opened the service in a new Internet Explorer Window.
VB.NET Code for this:
Private Sub Webbrowser1_NewWindow(sender As Object, e As CancelEventArgs) Handles WebBrowser1.NewWindow WebBrowser1.Navigate(WebBrowser1.StatusText) e.Cancel = True End Sub
Originally, I wanted to just wrap this in a HTA or something simple… but I got errors indicated that I couldn’t pull this in an iFrame. So I tried some Ajax/jQuery stuff in HTA and that was a complete fail (I’m not familiar with ajax/jquery things).
Very nice. I’d recommend using WPF instead of WinForms so if you have Windows 8 and Visual Studio 2012/2013 you can make it a metro app.
I may move that direction actually (WPF) because what I’m seeing is that the API is decent to use and I finally figured out how to access the user’s online SkyDrive (CID).