Solved

Converting VBA to C# code: opening browswer window

Posted on 2013-02-01
5
694 Views
Last Modified: 2013-02-08
Hi
I have some VBA code (used in a custom Excel Ribbon application) which I need the equivalent C# code for (rebuilding it in C# using Visual Studio).
The VBA code is shown below - basically it opens a 'minimalist' browser window  ()ie; without the toolbar etc..

Sub MOSS_ExchangeWiki(control As IRibbonControl)
        MsgBox "The web page will open in a Web browser window", vbInformation, "Opening  webpage..."
          Dim ie As Object
            Set ie = CreateObject("InternetExplorer.application")
            ie.Visible = True
            ie.Toolbar = False
            ie.StatusBar = False
            ie.MenuBar = False
            ie.navigate ("http://www.intel.com")
            ie.Top = 100
    End Sub

Open in new window


I have only got this far in C#:

public void OpenWebLink(IRibbonControl control)
{
Process.Start(@"http://www.intel.com")
}

Open in new window



Thanks for your help!!

Fergal
0
Comment
Question by:fjkilken
  • 3
  • 2
5 Comments
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
ID: 38843532
0
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
ID: 38843540
Use either ProcessStartInfo or ShellWindows.

Please do refer: http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.arguments.aspx as well.
0
 

Author Comment

by:fjkilken
ID: 38844670
thanks but I can't see any means to hide the Toolbar, MenuBar etc..
0
 

Accepted Solution

by:
fjkilken earned 0 total points
ID: 38850337
found a good solution online:  
 
      public void OpenLink(IRibbonControl control)
        {
        System.Type oType = System.Type.GetTypeFromProgID("InternetExplorer.Application");
        object o = System.Activator.CreateInstance(oType);
        o.GetType().InvokeMember("Navigate", System.Reflection.BindingFlags.InvokeMethod, null, o, new object[] { "www.intel.com" });
        o.GetType().InvokeMember("menubar", System.Reflection.BindingFlags.SetProperty, null, o, new object[] { 0 });
        o.GetType().InvokeMember("toolbar", System.Reflection.BindingFlags.SetProperty, null, o, new object[] { 0 });
        o.GetType().InvokeMember("statusBar", System.Reflection.BindingFlags.SetProperty, null, o, new object[] { 0 });
        o.GetType().InvokeMember("addressbar", System.Reflection.BindingFlags.SetProperty, null, o, new object[] { 0 });
        o.GetType().InvokeMember("Visible", System.Reflection.BindingFlags.SetProperty, null, o, new object[] { true });
           
        }

Open in new window

0
 

Author Closing Comment

by:fjkilken
ID: 38867436
This solution I found was just what I was looking for
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now