Solved

VB3: Access web site URL from program

Posted on 1998-06-18
6
472 Views
Last Modified: 2012-06-21
I would like to open the default browser and go to my web site (or any other URL) from my program (VB3).  I tried using"
ShellExecute(0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus)

(by the way, where is vbNullString defined? I would think this would give me an undefined error)

This worked at home.  I came in to work and tried it and the shellexecute returns a 2 (could not find file, i think, what file?) and does not open IE.

Thanks in advance,
Rob
0
Comment
Question by:RentRight
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1463726
Check if you have assosiation for .html files
0
 
LVL 1

Expert Comment

by:cip
ID: 1463727
If you're working with Windows NT, 16 bit ShellExecute will give error code 2 if the associated executable file exists in a directory path containing a long file name. This happens only on Windows NT systems, Windows 3.x and Windows 95 will work fine.You can find more info in Microsoft Knowledge base article Q172982.

0
 

Author Comment

by:RentRight
ID: 1463728
I am using windows 95, I checked the association by puting a shortcut on my desktop that was "http://www.rent-right.com"  This opens IE and dials in.

One other thing, I have two PC's at work.  One gives me an error (undefinded var.) for vbnullString, the other does not.  But both fail with a 2 from shellexecute.

Thanks for the help,
Rob
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

Author Comment

by:RentRight
ID: 1463729
Adjusted points to 120
0
 
LVL 1

Accepted Solution

by:
cip earned 120 total points
ID: 1463730
Rob,

VbNullString should give a "variable not defined" sintax error in vb3,
unless the "option explicit" statement is omitted in the declaration
section of the module.

The example below works fine on my PC, hope it can help since it is sligthly
different from yours. The second parameter in the ShellExecute declaration
is defined of type "Any" rather than "String", to allow passing a null pointer.
If you want to keep the "String" type, you should pass "open" as the second
parameter, for example:

ShellExecute(0&, "open", URL, "", "", 0)


--------------------------------------------
Declare Function ShellExecute Lib "shell.dll" (ByVal hwnd As Integer, ByVal lpOperation As Any, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Integer) As Integer

Sub Command1_Click ()
    Dim r As Integer
    Dim URL As String

    URL = "http://www.rent-right.com"
    r = ShellExecute(0&, 0&, URL, "", "", 0)
   debug.print r
end sub
--------------------------------------------

0
 

Author Comment

by:RentRight
ID: 1463731
Thanks, you got it.

It was the way I was declaring ShellExecute.  I used the declare out of the book using the Windows API with VB.  When I changed it to your declare, all of my previous versions worked.

Thanks again.
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pull multiple cvs files into one access table 28 68
vb6 programatically bring window to front 8 72
Excel VBA combine two working workbooks 8 55
Help me. 3 55
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

809 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