Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Microsoft Access > Re: Files launc...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 9 of 11 Topic 30191 of 31273
Post > Topic >>

Re: Files launched w/ Followhyperlink open but not visible

by "paii, Ron" <none@[EMAIL PROTECTED] > May 9, 2008 at 07:13 AM

"Ruben" <rubenfmunoz@[EMAIL PROTECTED]
> wrote in message
news:5091c851-aaf6-41ba-9417-975d4951df3a@[EMAIL PROTECTED]
 May 8, 1:21 pm, "paii, Ron" <n...@[EMAIL PROTECTED]
> wrote:
> "Ruben" <rubenfmu...@[EMAIL PROTECTED]
> wrote in message
>
>
news:877e8375-e061-44fd-8849-90bb86bd759e@[EMAIL PROTECTED]
>
> > 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 do***ent with
an
> associated program
>
> '************ Code Start **********
> ' This code was originally written by Dev A****sh.
> ' 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 A****sh
> '
> 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...@[EMAIL PROTECTED]
",WIN_NORMAL)
> 'Open URL: ?fHandleFile("http://home.att.net/~da****sh",
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 A****sh" who originally
posted the code, maybe there is a shell api that will wait for the shelled
to application to close.
 




 11 Posts in Topic:
Files launched w/ Followhyperlink open but not visible
Ruben <rubenfmunoz@[EM  2008-05-07 17:23:01 
Re: Files launched w/ Followhyperlink open but not visible
kaisersose1995 <kaiser  2008-05-08 02:24:47 
Re: Files launched w/ Followhyperlink open but not visible
Ruben <rubenfmunoz@[EM  2008-05-08 10:50:53 
Re: Files launched w/ Followhyperlink open but not visible
"Larry Linson"   2008-05-08 18:26:13 
Re: Files launched w/ Followhyperlink open but not visible
Ruben <rubenfmunoz@[EM  2008-05-08 11:50:07 
Re: Files launched w/ Followhyperlink open but not visible
"Larry Linson"   2008-05-09 00:15:03 
Re: Files launched w/ Followhyperlink open but not visible
"paii, Ron" <  2008-05-08 15:21:48 
Re: Files launched w/ Followhyperlink open but not visible
Ruben <rubenfmunoz@[EM  2008-05-08 15:19:52 
Re: Files launched w/ Followhyperlink open but not visible
"paii, Ron" <  2008-05-09 07:13:41 
Re: Files launched w/ Followhyperlink open but not visible
Ruben <rubenfmunoz@[EM  2008-05-09 08:55:25 
Re: Files launched w/ Followhyperlink open but not visible
Ruben <rubenfmunoz@[EM  2008-05-09 10:12:46 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 6 18:56:45 CDT 2008.