ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
Hi,
I am using the code shown below.
Simple combobox with a few site names within in.
I click on the site name & im taken there after clicking the command button.
Site names are shown in supplied photo.
I can click any site name & all fine APART from Royal Mail where i see a run time error & Internet server message,see attached photo.
When i click debug i see the text shown in red below selected.
What is starnge is that when i go to where the linnk is located & copy / paste in my browser it works.
Worksheet is called INFO
DC2 = DHL
DC3 = DPD
DC4 = MY HERMES
DC5 = ROYAL MAIL
To the right of these in column DD is the url
I am using the code shown below.
Simple combobox with a few site names within in.
I click on the site name & im taken there after clicking the command button.
Site names are shown in supplied photo.
I can click any site name & all fine APART from Royal Mail where i see a run time error & Internet server message,see attached photo.
When i click debug i see the text shown in red below selected.
What is starnge is that when i go to where the linnk is located & copy / paste in my browser it works.
Worksheet is called INFO
DC2 = DHL
DC3 = DPD
DC4 = MY HERMES
DC5 = ROYAL MAIL
To the right of these in column DD is the url
Rich (BB code):
Private Sub UserForm_Initialize()
Dim x As Integer 'This variable is just a number to count and go through each row on the active sheet
'to get each item that goes on the combobox
With Me.ComboBox1 'change it to the name of your combobox
.Clear
'Loop through each row,from row 2 to the last row with values in column A, and filling the Combobox with those values
For x = 2 To Sheets("INFO").Range("DC" & Sheets("INFO").Rows.Count).End(xlUp).Row
.AddItem Sheets("INFO").Range("DC" & x).Value
Next x
End With
End Sub
Private Sub OpenUrlPhoto_Click() 'This is Go button
Dim selected_item As String
selected_item = Me.ComboBox1.Text 'This will store the item you selected on your Combobox
'If no item was selected when button "GO" was clicked, then you will receive a alert message,
'and nothing will be done(That is done with the command 'exit sub', that will stop the code from running
If selected_item = "" Then
MsgBox "YOU MUST SELECT A WEB SITE URL FIRST.", vbCritical, "MUST SELECT A URL MESSAGE"
Exit Sub
End If
Dim url As String
'This is vlookup function to find the corresponding url on the active sheet
url = Application.WorksheetFunction.VLookup(selected_item, Sheets("INFO").Range("DC:DD"), 2, 0)
'This is how you open a hyperlink from your excel, using vba
ThisWorkbook.FollowHyperlink Address:=url, NewWindow:=True
Unload UrlPostage
End Sub