locked
Anybody know why the VB 6.5 (VBA) DoCmd.RunCommand acCmdOpenNewHyperlink does not work? RRS feed

  • Question

  • Also acCmdOpenHyperlink - does not have a function argument for the hyperlink URL to open, and gives the error "cannot use acCmdOpenHyperlink at this time".  Does this mean that this capability has been removed from this latest version of VBA?

    Thanks.

    R tj


    • Edited by TLJ_007 Monday, November 26, 2012 3:37 PM
    • Moved by Mark Liu-lxf Tuesday, November 27, 2012 3:14 AM VBA issue (From:Visual Basic Language)
    Monday, November 26, 2012 1:56 PM

All replies

  • Hi TLJ,

    Welcome to the MSDN forum.

    This forum is for VB.net, not VBA. Microsoft provides a special foum to deal with VBA issue. For better support, I will move this thread to VBA forum. It will cost a little time to involve the members in this forum. I appreciate your patience.

    Sorry for any incontinence and have a nice day.


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, November 27, 2012 3:15 AM
  • Hi TJ

    DoCmd is not VBA, it's an Access.Application Property, RunCommand is a method (Sub) of this property. You can see it also in the name of the parameter acCmdOpenNewHyperlink, where "ac" points to the Access object library constants.

    If you are running VBA outside of Access it will not know this property and you can't run the methods as long as you don't add the reference to the Microsoft Access Type Library. If you do so, then you will have access to it's objects, properties, methods and constants.

    HTH
    Henry

    "TLJ_007" schrieb im Newsbeitrag news:09b4c878-714d-4b60-a6b4-428af610a465@communitybridge.codeplex.com...

    Also acCmdOpenHyperlink - does not have a function argument for the
    hyperlink URL to open, and gives the error "cannot use
    acCmdOpenHyperlink at this time".  Does this mean that this capability
    has been removed from this latest version of VBA?

    Thanks.

    R tj

    Wednesday, November 28, 2012 5:51 AM
  • This is a code using API to open hiperlink. You can use this code in VBA form:

    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 text_Click() ShellExecute 0, "open", "http://social.msdn.microsoft.com", "", "", 0 end sub


    In VB.NET

        Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
            Try
                System.Diagnostics.Process.Start("http://social.msdn.microsoft.com")
    
            Catch ex As Exception
                MsgBox("No way.", _
                       MsgBoxStyle.Critical + MsgBoxStyle.MsgBoxSetForeground, "Err informaction - VBATools.pl")
            End Try
        End Sub


    Oskar Shon, Office System MVP

    Press if Helpful; Answer when a problem solved

    Wednesday, November 28, 2012 8:41 AM
    Answerer
  • Henry: don't understand what you are suggesting - use DoCmd or not?  If I do DoCmd.RunCommand (acCmdOpenURL) opens a prompt window works but does not accept an argument for the URL value.

    Oskar: Don't have shell32.dll in the library of VBA's Visual Basic 6.5; but do have "Microsoft Shell Controls and Automation library", which I activated to try your suggestion.  The "Shell" command works but the "ShellExecute" is not recognized. 

    Thanks for the tips!!!

    Thursday, November 29, 2012 1:54 PM
  • Hi TLJ

    I still don't know where you are running your VBA code. If you run it in Access the prefered approach is to use:

    Application.FollowHyperlink

    This one allows to pass parameters in the URL

    Here an exampe:

    Application.FollowHyperlink "http://yoururl/yourpage.aspx?parm1=1", , True, False

    HTH

    Henry



    • Edited by Henry Habermacher Monday, December 3, 2012 3:29 AM forgot the terminators for the string
    Friday, November 30, 2012 1:58 AM
  • ShellExecute is the API command - works every single Windows OS in all Office programs.

    so i have the same questions: "I still don't know where you are running your VBA code"


    Oskar Shon, Office System MVP

    Press if Helpful; Answer when a problem solved

    Sunday, December 2, 2012 8:43 PM
    Answerer