[thelist] [semi-OT] Opening Links from Combo Boxes in Excel

Ken Schaefer Ken at adOpenStatic.com
Sun Apr 3 03:39:25 CDT 2005

Why are you trying to use the Shell?

The Excel Workbook object has a .FollowHyperlink method that seems ideal for
what you need to do:

FollowHyperlink Method

Displays a cached document, if it's already been downloaded. Otherwise, this
method resolves the hyperlink, downloads the target document, and displays
the document in the appropriate application.

expression.FollowHyperlink(Address, SubAddress, NewWindow, AddHistory,
ExtraInfo, Method, HeaderInfo)
expression    Required. An expression that returns a Workbook object.

Address    Required String. The address of the target document.

SubAddress    Optional Variant. The location within the target document. The
default value is the empty string.

NewWindow    Optional Variant. True to display the target application in a
new window. The default value is False.

AddHistory    Optional Variant. Not used. Reserved for future use.

ExtraInfo    Optional Variant. A String or byte array that specifies
additional information for HTTP to use to resolve the hyperlink. For example,
you can use ExtraInfo to specify the coordinates of an image map, the
contents of a form, or a FAT file name.

Method    Optional Variant. Specifies the way ExtraInfo is attached. Can be
one of the following MsoExtraInfoMethod constants.

MsoExtraInfoMethod type can be one of these MsoExtraInfoMethod constants. 
msoMethodGet. ExtraInfo is a String that's appended to the address. 
msoMethodPost. ExtraInfo is posted as a String or byte array. 

HeaderInfo    Optional Variant. A String that specifies header information
for the HTTP request. The defaut value is an empty string.

This example loads the document at example.microsoft.com in a new window and
adds it to the History folder.

ActiveWorkbook.FollowHyperlink Address:="http://example.microsoft.com", _



: From: thelist-bounces at lists.evolt.org [mailto:thelist-
: bounces at lists.evolt.org] On Behalf Of Rob Smith
: Subject: RE: [thelist] [semi-OT] Opening Links from Combo Boxes in Excel
: <snip>
: You have to make sure that it is in fact a hyperlink. Click
: Insert->Hyperlink and follow the directions. If you need to edit you can
: right click the cell and makes your edits
: </snip>
: No dice. You can't have a combobox selected and choose Insert>Hyperlink.
: That option is grayed out. I have gotten the following to work:
: Sub DropDown1_Change()
:     Dim RetVal
:     RetVal = Shell("C:\Program Files\Microsoft Office\Office\WINWORD.EXE",
: 1)
:     AppActivate RetVal
: End Sub
: but not this:
: Sub DropDown1_Change()
:     Dim RetVal
:     RetVal = Shell("http://www.thermon.com", 1)
:     AppActivate RetVal
: End Sub
: Says file doesn't exist. Then my next question is that I can point this to
: IExplore.exe or whatever. Does IE take arguments? Can Shell in the macro
: handle passing arguments? The manual doesn't suggest that I can do that.
: Rob

More information about the thelist mailing list