The following code can be placed in the (General) section of your VBA customization and be called from any other event, for example the BeforeUserChanged event.
Public Function OpenBrowser(ByVal URL As String) As Boolean
Dim res As Long
' it is mandatory that the URL is prefixed with http:// or https://
If InStr(1, URL, "http", vbTextCompare) <> 1 Then
URL = "http://" & URL
result = ShellExecute(0, "open", URL, vbNullString, vbNullString, vbNormalFocus) OpenBrowser = (result > 32)
You can call the ShellExecute() Windows API function from a Visual Basic for Applications in Microsoft Dynamics GP to start another program under Microsoft Windows. Use ShellExecute() instead of Shell (a Visual Basic statement) or WinExec() (a Windows API function) to work around the following limitation of the latter commands: With Shell and WinExec(), you cannot start an application by specifying a file name only. ShellExecute() uses the default programs associated to each file type. In the case of the above example, ShellExecute() automatically recognizes the prefix http in the URL and launches Internet Explorer (or the default browser application).
KB Article 224816 - Use ShellExecute to Launch the default browser, by Microsoft Support.
Until next post!
Mariano Gomez, MIS, MVP, MCP, PMP
Maximum Global Business, LLC