Re: Files launched w/ Followhyperlink open but not visible
- From: Ruben <rubenfmunoz@xxxxxxxxx>
- Date: Fri, 9 May 2008 08:55:25 -0700 (PDT)
On May 9, 5:13 am, "paii, Ron" <n...@xxxxxx> wrote:
"Ruben" <rubenfmu...@xxxxxxxxx> wrote in message
news:5091c851-aaf6-41ba-9417-975d4951df3a@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On May 8, 1:21 pm, "paii, Ron" <n...@xxxxxx> wrote:
"Ruben" <rubenfmu...@xxxxxxxxx> wrote in message
news:877e8375-e061-44fd-8849-90bb86bd759e@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello,
I am using the "Application.FollowHyperlink 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.Visible=True / False"
and "Screen.ActiveControl.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.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
'***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_MEM = 0&
Private Const ERROR_FILE_NOT_FOUND = 2&
Private Const ERROR_PATH_NOT_FOUND = 3&
Private Const ERROR_BAD_FORMAT = 11&
'***************Usage Examples***********************
'Open a folder: ?fHandleFile("C:\TEMP\",WIN_NORMAL)
'Call Email app: ?fHandleFile("mailto:das...@xxxxxxxxxxx",WIN_NORMAL)
'Open URL: ?fHandleFile("http://home.att.net/~dashish", WIN_NORMAL)
'Handle Unknown extensions (call Open With Dialog):
' ?fHandleFile("C:\TEMP\TestThis",Win_Normal)
'Start Access instance:
' ?fHandleFile("I:\mdbs\CodeNStuff.mdb", Win_NORMAL)
'****************************************************
Function fHandleFile(stFile 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,OpenAs_RunDLL "
_
& stFile, WIN_NORMAL)
lRet = (varTaskID <> 0)
Case ERROR_OUT_OF_MEM:
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_FORMAT:
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
.
- References:
- Files launched w/ Followhyperlink open but not visible
- From: Ruben
- Re: Files launched w/ Followhyperlink open but not visible
- From: paii, Ron
- Re: Files launched w/ Followhyperlink open but not visible
- From: Ruben
- Re: Files launched w/ Followhyperlink open but not visible
- From: paii, Ron
- Files launched w/ Followhyperlink open but not visible
- Prev by Date: Re: TransferSpread*** to .ADP dbo table
- Next by Date: Problem designing access tables/form
- Previous by thread: Re: Files launched w/ Followhyperlink open but not visible
- Next by thread: FileMaker Business Management Software
- Index(es):
Loading