Link to home
Start Free TrialLog in
Avatar of Chris Miller
Chris MillerFlag for United States of America

asked on

Shell "cmd.Exe", vbNormalFocus


I would I have this open to an IP address?

Private Sub Command4_Click()
Shell "c:\program files\internet explorer\iexplore.exe", vbNormalFocus
End Sub
SOLUTION
Avatar of codeconqueror
codeconqueror

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can also pass the address as a parameter to the IE application:

Shell """c:\program files\internet explorer\iexplore.exe"" 127.0.0.1", vbNormalFocus
Sorry for the double double posting posting...
Avatar of codeconqueror
codeconqueror

Yes, but then you are counting on the end user having Explorer and/or wanting to use Explorer.  If you use ShellExecute it will open it with the user's default browser, whether it be IE, or Opera, or Netscape.  Just a thought to keep in mind.  :)
Agreed.  Also not a great idea hard coding the location... My first thought was that shellexecute would fail when passed an IP address.  However, I found you can get around it by adding the http:// prefix:

Note to CMILLER, this is supporting the solution proposed by codeconqueror.

Option Explicit
Private Declare Function ShellExecute& Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
                                    ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long)

Private Sub Command1_Click()
    ShowIP "127.0.0.1"
End Sub

Private Sub ShowIP(ByVal strAddress As String)

    If LCase(Left$(strAddress, 7)) <> "http://" Then
        strAddress = "http://" & strAddress
    End If
   
    ShellExecute Me.hWnd, "open", strAddress, vbNullString, vbNullString, vbNormalFocus
   
End Sub
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Chris Miller

ASKER

To ALL,

I was looking to hard code, I am building a form to manage my network switches.

I would like to give all of you some points, they are all good solutions.

Thanks