Files launched w/ Followhyperlink open but not visible

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ruben

    Files launched w/ Followhyperlink open but not visible

    Hello,

    I am using the "Application.Fo llowHyperlink strFilePath, , True" line
    of code from within access forms to launch any file type I want (e.g.,
    xls, doc, pdf, etc.). The files open up okay, but open up in the
    background. How do I make them open in front where they are visible?
    I have tried various things like "Appliction.Vis ible=True / False"
    and "Screen.ActiveC ontrol.Visible= True / False" but have not been able
    to figure it out.

    Anyones help with this would be very much appreciated.

    Regards,

    Ruben Munoz
  • kaisersose1995

    #2
    Re: Files launched w/ Followhyperlink open but not visible

    On 8 May, 01:23, Ruben <rubenfmu...@gm ail.comwrote:
    Hello,
    >
    I am using the "Application.Fo llowHyperlink strFilePath, , True" line
    of code from within access forms to launch any file type I want (e.g.,
    xls, doc, pdf, etc.).  The files open up okay, but open up in the
    background.  How do I make them open in front where they are visible?
    I have tried various things like  "Appliction.Vis ible=True / False"
    and "Screen.ActiveC ontrol.Visible= True / False" but have not been able
    to figure it out.
    >
    Anyones help with this would be very much appreciated.
    >
    Regards,
    >
    Ruben Munoz

    Instead of using FollowHyperlink have you considered using the Shell
    command?
    e.g
    Shell("C:\MSOff ice\OFFICE11\WI NWORD.EXE C:\Somedir\..\. .
    \somefile.doc", vbMaximizedFocu s)

    this will open the word doc somefile, maximised on top of all other
    windows.

    Regards

    Richard

    Comment

    • paii, Ron

      #3
      Re: Files launched w/ Followhyperlink open but not visible


      "Ruben" <rubenfmunoz@gm ail.comwrote in message
      news:877e8375-e061-44fd-8849-90bb86bd759e@y2 1g2000hsf.googl egroups.com...
      Hello,
      >
      I am using the "Application.Fo llowHyperlink strFilePath, , True" line
      of code from within access forms to launch any file type I want (e.g.,
      xls, doc, pdf, etc.). The files open up okay, but open up in the
      background. How do I make them open in front where they are visible?
      I have tried various things like "Appliction.Vis ible=True / False"
      and "Screen.ActiveC ontrol.Visible= True / False" but have not been able
      to figure it out.
      >
      Anyones help with this would be very much appreciated.
      >
      Regards,
      >
      Ruben Munoz
      I have been using the following code to open any type of document with an
      associated program


      '************ Code Start **********
      ' This code was originally written by Dev Ashish.
      ' It is not to be altered or distributed,
      ' except as part of an application.
      ' You are free to use it in any application,
      ' provided the copyright notice is left unchanged.
      '
      ' Code Courtesy of
      ' Dev Ashish
      '
      Private Declare Function apiShellExecute Lib "shell32.dl l" _
      Alias "ShellExecu teA" _
      (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

      '***App Window Constants***
      Public Const WIN_NORMAL = 1 'Open Normal
      Public Const WIN_MAX = 3 'Open Maximized
      Public Const WIN_MIN = 2 'Open Minimized

      '***Error Codes***
      Private Const ERROR_SUCCESS = 32&
      Private Const ERROR_NO_ASSOC = 31&
      Private Const ERROR_OUT_OF_ME M = 0&
      Private Const ERROR_FILE_NOT_ FOUND = 2&
      Private Const ERROR_PATH_NOT_ FOUND = 3&
      Private Const ERROR_BAD_FORMA T = 11&

      '************** *Usage Examples******* *************** *
      'Open a folder: ?fHandleFile("C :\TEMP\",WIN_NO RMAL)
      'Call Email app: ?fHandleFile("m ailto:dash10@ho tmail.com",WIN_ NORMAL)
      'Open URL: ?fHandleFile("h ttp://home.att.net/~dashish", WIN_NORMAL)
      'Handle Unknown extensions (call Open With Dialog):
      ' ?fHandleFile("C :\TEMP\TestThis ",Win_Norma l)
      'Start Access instance:
      ' ?fHandleFile("I :\mdbs\CodeNStu ff.mdb", Win_NORMAL)
      '************** *************** *************** ********

      Function fHandleFile(stF ile As String, lShowHow As Long)
      Dim lRet As Long, varTaskID As Variant
      Dim stRet As String
      'First try ShellExecute
      lRet = apiShellExecute (hWndAccessApp, vbNullString, _
      stFile, vbNullString, vbNullString, lShowHow)

      If lRet ERROR_SUCCESS Then
      stRet = vbNullString
      lRet = -1
      Else
      Select Case lRet
      Case ERROR_NO_ASSOC:
      'Try the OpenWith dialog
      varTaskID = Shell("rundll32 .exe shell32.dll,Ope nAs_RunDLL "
      _
      & stFile, WIN_NORMAL)
      lRet = (varTaskID <0)
      Case ERROR_OUT_OF_ME M:
      stRet = "Error: Out of Memory/Resources. Couldn't Execute!"
      Case ERROR_FILE_NOT_ FOUND:
      stRet = "Error: File not found. Couldn't Execute!"
      Case ERROR_PATH_NOT_ FOUND:
      stRet = "Error: Path not found. Couldn't Execute!"
      Case ERROR_BAD_FORMA T:
      stRet = "Error: Bad File Format. Couldn't Execute!"
      Case Else:
      End Select
      End If
      fHandleFile = lRet & _
      IIf(stRet = "", vbNullString, ", " & stRet)
      End Function
      '************ Code End **********


      Comment

      • Ruben

        #4
        Re: Files launched w/ Followhyperlink open but not visible

        On May 8, 1:21 pm, "paii, Ron" <n...@no.comwro te:
        "Ruben" <rubenfmu...@gm ail.comwrote in message
        >
        news:877e8375-e061-44fd-8849-90bb86bd759e@y2 1g2000hsf.googl egroups.com...
        >
        Hello,
        >
        I am using the "Application.Fo llowHyperlink strFilePath, , True" line
        of code from within access forms to launch any file type I want (e.g.,
        xls, doc, pdf, etc.).  The files open up okay, but open up in the
        background.  How do I make them open in front where they are visible?
        I have tried various things like  "Appliction.Vis ible=True / False"
        and "Screen.ActiveC ontrol.Visible= True / False" but have not been able
        to figure it out.
        >
        Anyones help with this would be very much appreciated.
        >
        Regards,
        >
        Ruben Munoz
        >
        I have been using the following code to open any type of document with an
        associated program
        >
        '************ Code Start **********
        ' This code was originally written by Dev Ashish.
        ' It is not to be altered or distributed,
        ' except as part of an application.
        ' You are free to use it in any application,
        ' provided the copyright notice is left unchanged.
        '
        ' Code Courtesy of
        ' Dev Ashish
        '
        Private Declare Function apiShellExecute Lib "shell32.dl l" _
            Alias "ShellExecu teA" _
            (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
        >
        '***App Window Constants***
        Public Const WIN_NORMAL = 1         'Open Normal
        Public Const WIN_MAX = 3            'Open Maximized
        Public Const WIN_MIN = 2            'Open Minimized
        >
        '***Error Codes***
        Private Const ERROR_SUCCESS = 32&
        Private Const ERROR_NO_ASSOC = 31&
        Private Const ERROR_OUT_OF_ME M = 0&
        Private Const ERROR_FILE_NOT_ FOUND = 2&
        Private Const ERROR_PATH_NOT_ FOUND = 3&
        Private Const ERROR_BAD_FORMA T = 11&
        >
        '************** *Usage Examples******* *************** *
        'Open a folder:     ?fHandleFile("C :\TEMP\",WIN_NO RMAL)
        'Call Email app:    ?fHandleFile("m ailto:das...@ho tmail.com",WIN_ NORMAL)
        'Open URL:          ?fHandleFile("h ttp://home.att.net/~dashish",WIN_N ORMAL)
        'Handle Unknown extensions (call Open With Dialog):
        '                   ?fHandleFile("C :\TEMP\TestThis ",Win_Norma l)
        'Start Access instance:
        '                   ?fHandleFile("I :\mdbs\CodeNStu ff.mdb", Win_NORMAL)
        '************** *************** *************** ********
        >
        Function fHandleFile(stF ile As String, lShowHow As Long)
        Dim lRet As Long, varTaskID As Variant
        Dim stRet As String
            'First try ShellExecute
            lRet = apiShellExecute (hWndAccessApp, vbNullString, _
                    stFile, vbNullString, vbNullString, lShowHow)
        >
            If lRet ERROR_SUCCESS Then
                stRet = vbNullString
                lRet = -1
            Else
                Select Case lRet
                    Case ERROR_NO_ASSOC:
                        'Try the OpenWith dialog
                        varTaskID = Shell("rundll32 .exe shell32.dll,Ope nAs_RunDLL "
        _
                                & stFile, WIN_NORMAL)
                        lRet = (varTaskID <0)
                    Case ERROR_OUT_OF_ME M:
                        stRet = "Error: Out of Memory/Resources.Could n't Execute!"
                    Case ERROR_FILE_NOT_ FOUND:
                        stRet = "Error: File not found.  Couldn't Execute!"
                    Case ERROR_PATH_NOT_ FOUND:
                        stRet = "Error: Path not found. Couldn'tExecute !"
                    Case ERROR_BAD_FORMA T:
                        stRet = "Error:  Bad File Format. Couldn't Execute!"
                    Case Else:
                End Select
            End If
            fHandleFile = lRet & _
                        IIf(stRet = "", vbNullString, ", " & stRet)
        End Function
        '************ Code End **********
        Ron,

        Thanks very much for the sample code provided. The ShellExecute part
        of the code work great! Is there any way to redirect the focus to
        access upon closing the external file just launched? Otherwise, I can
        certainly work with this.

        Ruben

        Comment

        • paii, Ron

          #5
          Re: Files launched w/ Followhyperlink open but not visible


          "Ruben" <rubenfmunoz@gm ail.comwrote in message
          news:5091c851-aaf6-41ba-9417-975d4951df3a@34 g2000hsf.google groups.com...
          On May 8, 1:21 pm, "paii, Ron" <n...@no.comwro te:
          "Ruben" <rubenfmu...@gm ail.comwrote in message
          >
          news:877e8375-e061-44fd-8849-90bb86bd759e@y2 1g2000hsf.googl egroups.com...
          >
          Hello,
          >
          I am using the "Application.Fo llowHyperlink strFilePath, , True" line
          of code from within access forms to launch any file type I want (e.g.,
          xls, doc, pdf, etc.). The files open up okay, but open up in the
          background. How do I make them open in front where they are visible?
          I have tried various things like "Appliction.Vis ible=True / False"
          and "Screen.ActiveC ontrol.Visible= True / False" but have not been able
          to figure it out.
          >
          Anyones help with this would be very much appreciated.
          >
          Regards,
          >
          Ruben Munoz
          >
          I have been using the following code to open any type of document with an
          associated program
          >
          '************ Code Start **********
          ' This code was originally written by Dev Ashish.
          ' It is not to be altered or distributed,
          ' except as part of an application.
          ' You are free to use it in any application,
          ' provided the copyright notice is left unchanged.
          '
          ' Code Courtesy of
          ' Dev Ashish
          '
          Private Declare Function apiShellExecute Lib "shell32.dl l" _
          Alias "ShellExecu teA" _
          (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
          >
          '***App Window Constants***
          Public Const WIN_NORMAL = 1 'Open Normal
          Public Const WIN_MAX = 3 'Open Maximized
          Public Const WIN_MIN = 2 'Open Minimized
          >
          '***Error Codes***
          Private Const ERROR_SUCCESS = 32&
          Private Const ERROR_NO_ASSOC = 31&
          Private Const ERROR_OUT_OF_ME M = 0&
          Private Const ERROR_FILE_NOT_ FOUND = 2&
          Private Const ERROR_PATH_NOT_ FOUND = 3&
          Private Const ERROR_BAD_FORMA T = 11&
          >
          '************** *Usage Examples******* *************** *
          'Open a folder: ?fHandleFile("C :\TEMP\",WIN_NO RMAL)
          'Call Email app: ?fHandleFile("m ailto:das...@ho tmail.com",WIN_ NORMAL)
          'Open URL: ?fHandleFile("h ttp://home.att.net/~dashish", WIN_NORMAL)
          'Handle Unknown extensions (call Open With Dialog):
          ' ?fHandleFile("C :\TEMP\TestThis ",Win_Norma l)
          'Start Access instance:
          ' ?fHandleFile("I :\mdbs\CodeNStu ff.mdb", Win_NORMAL)
          '************** *************** *************** ********
          >
          Function fHandleFile(stF ile As String, lShowHow As Long)
          Dim lRet As Long, varTaskID As Variant
          Dim stRet As String
          'First try ShellExecute
          lRet = apiShellExecute (hWndAccessApp, vbNullString, _
          stFile, vbNullString, vbNullString, lShowHow)
          >
          If lRet ERROR_SUCCESS Then
          stRet = vbNullString
          lRet = -1
          Else
          Select Case lRet
          Case ERROR_NO_ASSOC:
          'Try the OpenWith dialog
          varTaskID = Shell("rundll32 .exe shell32.dll,Ope nAs_RunDLL "
          _
          & stFile, WIN_NORMAL)
          lRet = (varTaskID <0)
          Case ERROR_OUT_OF_ME M:
          stRet = "Error: Out of Memory/Resources. Couldn't Execute!"
          Case ERROR_FILE_NOT_ FOUND:
          stRet = "Error: File not found. Couldn't Execute!"
          Case ERROR_PATH_NOT_ FOUND:
          stRet = "Error: Path not found. Couldn't Execute!"
          Case ERROR_BAD_FORMA T:
          stRet = "Error: Bad File Format. Couldn't Execute!"
          Case Else:
          End Select
          End If
          fHandleFile = lRet & _
          IIf(stRet = "", vbNullString, ", " & stRet)
          End Function
          '************ Code End **********
          Ron,

          Thanks very much for the sample code provided. The ShellExecute part
          of the code work great! Is there any way to redirect the focus to
          access upon closing the external file just launched? Otherwise, I can
          certainly work with this.

          Ruben

          Glad the code helped.
          The ShellExecute function returns after attempting to open the file with
          success or fail. At that point your Access application has no control over
          the shelled application. Maybe check with the "Dev Ashish" who originally
          posted the code, maybe there is a shell api that will wait for the shelled
          to application to close.


          Comment

          • Ruben

            #6
            Re: Files launched w/ Followhyperlink open but not visible

            On May 9, 5:13 am, "paii, Ron" <n...@no.comwro te:
            "Ruben" <rubenfmu...@gm ail.comwrote in message
            >
            news:5091c851-aaf6-41ba-9417-975d4951df3a@34 g2000hsf.google groups.com...
            On May 8, 1:21 pm, "paii, Ron" <n...@no.comwro te:
            >
            >
            >
            >
            >
            "Ruben" <rubenfmu...@gm ail.comwrote in message
            >
            news:877e8375-e061-44fd-8849-90bb86bd759e@y2 1g2000hsf.googl egroups.com...
            >
            Hello,
            >
            I am using the "Application.Fo llowHyperlink strFilePath, , True" line
            of code from within access forms to launch any file type I want (e.g.,
            xls, doc, pdf, etc.). The files open up okay, but open up in the
            background. How do I make them open in front where they are visible?
            I have tried various things like "Appliction.Vis ible=True / False"
            and "Screen.ActiveC ontrol.Visible= True / False" but have not been able
            to figure it out.
            >
            Anyones help with this would be very much appreciated.
            >
            Regards,
            >
            Ruben Munoz
            >
            I have been using the following code to open any type of document with an
            associated program
            >
            '************ Code Start **********
            ' This code was originally written by Dev Ashish.
            ' It is not to be altered or distributed,
            ' except as part of an application.
            ' You are free to use it in any application,
            ' provided the copyright notice is left unchanged.
            '
            ' Code Courtesy of
            ' Dev Ashish
            '
            Private Declare Function apiShellExecute Lib "shell32.dl l" _
            Alias "ShellExecu teA" _
            (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
            >
            '***App Window Constants***
            Public Const WIN_NORMAL = 1 'Open Normal
            Public Const WIN_MAX = 3 'Open Maximized
            Public Const WIN_MIN = 2 'Open Minimized
            >
            '***Error Codes***
            Private Const ERROR_SUCCESS = 32&
            Private Const ERROR_NO_ASSOC = 31&
            Private Const ERROR_OUT_OF_ME M = 0&
            Private Const ERROR_FILE_NOT_ FOUND = 2&
            Private Const ERROR_PATH_NOT_ FOUND = 3&
            Private Const ERROR_BAD_FORMA T = 11&
            >
            '************** *Usage Examples******* *************** *
            'Open a folder: ?fHandleFile("C :\TEMP\",WIN_NO RMAL)
            'Call Email app: ?fHandleFile("m ailto:das...@ho tmail.com",WIN_ NORMAL)
            'Open URL: ?fHandleFile("h ttp://home.att.net/~dashish", WIN_NORMAL)
            'Handle Unknown extensions (call Open With Dialog):
            ' ?fHandleFile("C :\TEMP\TestThis ",Win_Norma l)
            'Start Access instance:
            ' ?fHandleFile("I :\mdbs\CodeNStu ff.mdb", Win_NORMAL)
            '************** *************** *************** ********
            >
            Function fHandleFile(stF ile As String, lShowHow As Long)
            Dim lRet As Long, varTaskID As Variant
            Dim stRet As String
            'First try ShellExecute
            lRet = apiShellExecute (hWndAccessApp, vbNullString, _
            stFile, vbNullString, vbNullString, lShowHow)
            >
            If lRet ERROR_SUCCESS Then
            stRet = vbNullString
            lRet = -1
            Else
            Select Case lRet
            Case ERROR_NO_ASSOC:
            'Try the OpenWith dialog
            varTaskID = Shell("rundll32 .exe shell32.dll,Ope nAs_RunDLL "
            _
            & stFile, WIN_NORMAL)
            lRet = (varTaskID <0)
            Case ERROR_OUT_OF_ME M:
            stRet = "Error: Out of Memory/Resources. Couldn't Execute!"
            Case ERROR_FILE_NOT_ FOUND:
            stRet = "Error: File not found. Couldn't Execute!"
            Case ERROR_PATH_NOT_ FOUND:
            stRet = "Error: Path not found. Couldn't Execute!"
            Case ERROR_BAD_FORMA T:
            stRet = "Error: Bad File Format. Couldn't Execute!"
            Case Else:
            End Select
            End If
            fHandleFile = lRet & _
            IIf(stRet = "", vbNullString, ", " & stRet)
            End Function
            '************ Code End **********
            >
            Ron,
            >
            Thanks very much for the sample code provided.  The ShellExecute part
            of the code work great!  Is there any way to redirect the focus to
            access upon closing the external file just launched?  Otherwise, I can
            certainly work with this.
            >
            Ruben
            >
            Glad the code helped.
            The ShellExecute function returns after attempting to open the file with
            success or fail. At that point your Access application has no control over
            the shelled application. Maybe check with the "Dev Ashish" who originally
            posted the code, maybe there is a shell api that will wait for the shelled
            to application to close.- Hide quoted text -
            >
            - Show quoted text -
            Ron,

            Thanks again for your help on this. It gives something more to work
            with.

            Regards,

            Ruben

            Comment

            Working...