Cannot locate the internet server message

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,832
Office Version
  1. 2007
Platform
  1. 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


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
 

Attachments

  • 2924.jpg
    2924.jpg
    64 KB · Views: 12
  • 2925.jpg
    2925.jpg
    24.7 KB · Views: 12

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
As a test i swapped the My Hermes & Royal Mail url around.
So now i click Royal Mail & the My Hermes website opened fine.
When i clicked on My Hermes the error popped up.
This tells me the url address isnt like by the code.

Like mentioned if i copy / paste the url into the web browser it works fine
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top