Solved

Converting VBA to C# code: opening browswer window

Posted on 2013-02-01
5
731 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This article describes a serious pitfall that can happen when deleting shapes using VBA.
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…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

751 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