Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Converting VBA to C# code: opening browswer window

Posted on 2013-02-01
5
Medium Priority
?
775 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: 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

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!
Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

972 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