Web URL Built Into Code is Opening a Tab per Field Instead of One Tab for All Fields....

BrianExcel

Well-known Member
Joined
Apr 21, 2010
Messages
975
I am using code to generate a URL and open Chrome to navigate to that URL. However, what's happening now is that a tab within Chrome is being entered for each field I am passing *address, city, state, etc.) rather that 1 tab opening with a single URL.

The other complication, is that when I open Chrome manually and enter the same URL physically into the address box, the window opens just fine.

Any idea how I can stop that from happening? Here is the code.

Code:
Sub btnSubmitForDirections_Click()Dim sAddress As String, sCity As String, sState As String, sZip As String, sStartPoint As String
Dim eAddress As String, eCity As String, eState As String, eZip As String, sEndPoint As String


With EnterDirections
    sAddress = .txtAddress
    sCity = .txtCity
    sState = .cmbState
    'sZip = .txtZip
End With


For x = 0 To UserForm1.lbxSiteInfo.ListCount - 1
    If UserForm1.lbxSiteInfo.Selected(x) Then
        eAddress = UserForm1.lbxSiteInfo.List(x, 3)
        eCity = UserForm1.lbxSiteInfo.List(x, 4)
        eState = UserForm1.lbxSiteInfo.List(x, 5)
        'eZip = UserForm1.lbxSiteInfo.List(x, 6)
    End If
Next


sStartPoint = sAddress & ", " & sCity & ", " & sState
sEndPoint = eAddress & ", " & eCity & ", " & eState


sWebURL = "https://www.google.com/maps/dir/" & sStartPoint & "/" & sEndPoint


Unload Me


Shell ("C:\Program Files (x86)\Google\Chrome\Application\Chrome.exe -url " & sWebURL)


End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Okay, sorry, I figured it out - I had to replace the spaces in the string with "+" to make the google URL work correctly. I re-established the sStartPoint and sEndPoint as the following, which then worked:

Code:
    sStartPoint = Replace(sStartPoint, " ", "+")    sEndPoint = Replace(sEndPoint, " ", "+")
 
Upvote 0

Forum statistics

Threads
1,215,554
Messages
6,125,487
Members
449,233
Latest member
Deardevil

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