Solved

Converting VBA to C# code: opening browswer window

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
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…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

762 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

17 Experts available now in Live!

Get 1:1 Help Now