Open a webpage from VBA

Solved
fourvin Posted messages 286 Status Member -  
fourvin Posted messages 286 Status Member -
Good evening,

I am using Office 2007 and I am looking for a way to open a given Internet URL from a VBA procedure.
For example, how can I use VBA to open the URL http://www.commentcamarche.net in my default browser?

Thank you in advance for the answers.

Configuration: Windows 7 / Firefox 3.6.10

1 answer

  1. cousinhub29 Posted messages 1166 Registration date   Status Member Last intervention   415
     
    Hello,

    Test carried out with FF first, then IE, and then again FF as the default browser....

    In a standard module:

    Option Explicit Public Declare Function ShellExecute Lib "shell32.dll" _ Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _ ByVal lpFile As String, ByVal lpParameters As String, _ ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Sub Open() Dim File As String File = "https://www.commentcamarche.net/" ShellExecute 0, "", File, "", "", 0 End Sub


    Good night
    11
    1. fourvin Posted messages 286 Status Member 102
       
      Thank you for your response. In my further research after my question, I also came across this code, but I was hoping there was a simpler VBA function!

      Thank you.
      0
    2. fourvin Posted messages 286 Status Member 102
       
      Good evening,

      I was also provided with this simplified version for Access, likely degraded, but which I had no problem using:

      Public Function fIE(wID As String, wCHEM As String) ' In a form control, opens the URL corresponding to the code ' wCHEM=base path of the site http://... ' WID=page identifier Dim A A = Shell("C:\Program Files\Internet Explorer\iexplore.exe "+wCHEM+wID, vbNormalFocus) End Function 
      0