NewYears1978
Board Regular
- Joined
- Feb 25, 2014
- Messages
- 107
Hey all. I have a macro that asks the user which browser they prefer, then sets that location in a variable. Then in a worksheet I have a follow hyperlink macro that uses that variable however the variable information is not being passed.
The info is being stored properly because the msgbox at the end of the inputbox macro shows correct. What am I missing?
The global car is called AppLoc
My main macro is in a module:
Then on a worksheet I have this
Nothing is being displayed for AppLoc and the macro isn't working. Some how the variable is not being passed...what am I doing wrong? Thanks in advance
The info is being stored properly because the msgbox at the end of the inputbox macro shows correct. What am I missing?
The global car is called AppLoc
My main macro is in a module:
Code:
Option Explicit
Global AppLoc As String
Public Function ChooseBrowser() As String
Dim s As String
s = InputBox("Please type in your number of your preferred browser:" & vbCrLf & _
vbCrLf & vbTab & "1 for Chrome" & _
vbCrLf & vbTab & "2 for Firefox" & _
vbCrLf & vbTab & "3 for Edge", "Option Chooser")
Select Case s
Case "1"
If Dir("C:\Program Files\Google\Chrome\Application", vbDirectory) <> "" Then '64 bit paths
AppLoc = "C:\Program Files\Google\Chrome\Application\chrome.exe"
Else '32 bit paths (some 32 and 64 are the same)
AppLoc = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
End If
Case "2"
If Dir("C:\Program Files\Google\Chrome\Application", vbDirectory) <> "" Then '64 bit paths
AppLoc = "C:\Program Files\Mozilla Firefox\firefox.exe"
Else '32 bit paths (some 32 and 64 are the same)
AppLoc = "C:\Program Files\Mozilla Firefox\firefox.exe"
End If
Case "3"
If Dir("C:\Program Files\Google\Chrome\Application", vbDirectory) <> "" Then '64 bit paths
AppLoc = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
Else '32 bit paths (some 32 and 64 are the same)
AppLoc = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
End If
Case Else
End Select
MsgBox AppLoc
End Function
Then on a worksheet I have this
Code:
Option Explicit
Private Sub Worksheet_FollowHyperlink(ByVal objLink As Hyperlink)
Application.EnableEvents = False
Dim strAddress As String
MsgBox AppLoc
If ActiveCell.Column = 21 Then
strAddress = "https://www.1000bulbs.com/customer/sales_edit/" & objLink.Parent.Offset(0, -19).Value
Else
strAddress = objLink.Parent.Offset(0, -1).Value
End If
Dim dblReturn As Double
dblReturn = Shell(AppLoc & " " & strAddress, 1)
Application.EnableEvents = True
End Sub
Nothing is being displayed for AppLoc and the macro isn't working. Some how the variable is not being passed...what am I doing wrong? Thanks in advance