Solved

Converting VBA to C# code: opening browswer window

Posted on 2013-02-01
5
711 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

791 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