On May 8, 5:15=A0pm, "Larry Linson" <boun...@[EMAIL PROTECTED]
> wrote:
> It appears that you got a useful answer on using Shell. =A0My initial
deta=
il
> look at that had led me to a more complicated solution, which I did not
> think would be appropriate... but I did not try it.
>
> What I did try was a simple test of Application.FollowHyperlink to see
if =
I
> could "force" the file to open in the background as you described, by
> setting the active form from whose code it was executed to PopUp or
Modal.=
> And it turned out that I could not... the application opened by
> FollowHyperlink always opened in the foreground... Normal, PopUp or
Modal.=
> Then when I closed that application's window, focus in each case
returned =
to
> the Access application that was opened behind it. I tried it on a .JPG
> opened with Paint Shop Pro 9 and a Spreadsheet opened with Microsoft
Excel=
> 2003.
>
> I created a simple, unbound form with two command buttons. =A0In the
Gener=
al,
> Declarations section of the Form's module, I defined
>
> =A0Dim strPathAndFile As String
>
> Slightly modified from the API0001 code, was the click event:
>
> =A0Private Sub cmdBrowse_Click()
> =A0On Error GoTo Err_cmdBrowse_Click
>
> =A0 =A0 Dim strFilter As String
> =A0 =A0 Dim lngFlags As Long
> =A0' =A0 =A0strFilter =3D ahtAddFilterItem(strFilter, "Access Files
(*.mda=
, *.mdb)",
> _
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "*.MDA;*.MDB")
> =A0' =A0 =A0strFilter =3D ahtAddFilterItem(strFilter, "dBASE Files
(*.dbf)=
",
> "*.DBF")
> =A0' =A0 =A0strFilter =3D ahtAddFilterItem(strFilter, "Text Files
(*.txt)"=
, "*.TXT")
> =A0 =A0 =A0strFilter =3D ahtAddFilterItem(strFilter, "All Files (*.*)",
"*=
..*")
> =A0 =A0 =A0strPathAndFile =3D ahtCommonFileOpenSave(InitialDir:=3D"C:\",
_=
> =A0 =A0 =A0 =A0 Filter:=3DstrFilter, FilterIndex:=3D3,
Flags:=3DlngFlags, =
_
> =A0 =A0 =A0 =A0 DialogTitle:=3D"Hello! Open Me!")
>
> =A0 =A0 MsgBox "You selected: " & strPathAndFile
> =A0 =A0 ' Since you passed in a variable for lngFlags,
> =A0 =A0 ' the function places the output flags value in the variable.
> =A0 =A0 Debug.Print Hex(lngFlags)
>
> =A0Exit_cmdBrowse_Click:
> =A0 =A0 Exit Sub
>
> =A0Err_cmdBrowse_Click:
> =A0 =A0 MsgBox Err.Description
> =A0 =A0 Resume Exit_cmdBrowse_Click
>
> End Sub
>
> And, in the other button's click event, the following to open the file
by
> hyperlinking (and by the way, I tried this with both True and False for
th=
e
> New Window argument.
>
> Private Sub cmdFollowHyperlink_Click()
> On Error GoTo Err_cmdFollowHyperlink_Click
>
> =A0 =A0 Application.FollowHyperlink strPathAndFile, , False, True
>
> Exit_cmdFollowHyperlink_Click:
> =A0 =A0 Exit Sub
>
> Err_cmdFollowHyperlink_Click:
> =A0 =A0 MsgBox Err.Description
> =A0 =A0 Resume Exit_cmdFollowHyperlink_Click
>
> End Sub
>
> Summary: I could not reproduce what you describe, so I'm wondering what
fo=
rm
> or application settings in the Access application might cause the file
to
> open behind it. =A0My testing was done in Access 2003 (using 2002/2003
fil=
e
> format).
>
> Why don't you compare my code with yours and perhaps create a new Access
> application -- nothing "fancy" or out of the ordinary, to see if it
works
> for you as it did before, or as it does for me.
>
> =A0Larry Linson
> =A0Microsoft Office Access MVP
>
> "Ruben" <rubenfmu...@[EMAIL PROTECTED]
> wrote in message
>
> news:57de549a-6d89-4450-9119-e488e29415b6@[EMAIL PROTECTED]
> On May 8, 11:26 am, "Larry Linson" <boun...@[EMAIL PROTECTED]
> wrote:
>
>
>
>
>
> > You can use the code
athttp://www.mvps.org/access/api/api0001.htmtoopen
> > the Windows Common Dialog to allow the user to choose a file, and then
y=
ou
> > can use VBA code to use that file selection in the Shell function.
>
> > When you follow hyperlink, it opens an instance of the software
register=
ed
> > for the file-type... that is not part of your Application, nor in a
> > Control
> > in your application. You would have to determine some API that would
mak=
e
> > it
> > the active window, or perhaps you could minimize the Access database
you=
> > are
> > running.
>
> > Larry Linson
> > Microsoft Office Access MVP
>
> > "Ruben" <rubenfmu...@[EMAIL PROTECTED]
> wrote in message
>
>
>news:d3c34892-136a-4fae-ba22-409949de6909@[EMAIL PROTECTED]
> > On May 8, 2:24 am, kaisersose1995 <kaisersose1...@[EMAIL PROTECTED]
> wrote:
>
> > > On 8 May, 01:23, Ruben <rubenfmu...@[EMAIL PROTECTED]
> wrote:
>
> > > > Hello,
>
> > > > I am using the "Application.FollowHyperlink strFilePath, , True"
lin=
e
> > > > 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=3DTrue /
False"=
> > > > and "Screen.ActiveControl.Visible=3DTrue / 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:\MSOffice\OFFICE11\WINWORD.EXE C:\Somedir\..\..
> > > \somefile.doc", vbMaximizedFocus)
>
> > > this will open the word doc somefile, maximised on top of all other
> > > windows.
>
> > > Regards
>
> > > Richard
>
> > Thanks for your response. Yes I have considered the Shell command.
> > And although the Shell command works, I can't figure out how to make
> > it work within my application.
>
> > I am using Access 2000. What this part of my application does is that
> > it enables users to click on a hyperlink text field within a form in
> > order to "attach" external do***ents such as xls, doc, pdf, etc., to
> > the form. This launches the Open File Dialog from which they can
> > select the file they want to "attach". Once a selection has been
> > made, the file path to their do***ent is captured to that text field
> > as a hyperlink that launches their file or do***ent the next time a
> > user clicks on it.
>
> > Unless there's a way to assign the "attached" file path within the
> > Shell command to a string or variable, I don't know if the Shell
> > command could be made to work in this case. As it stands now,
> > "Application.FollowHyperlink strFilePath, , True" is the only other
> > line of code I found that works to the extent of opening up external
> > files or applications, I just can't get these to open up on top.
>
> > -Ruben- Hide quoted text -
>
> > - Show quoted text -
>
> Larry,
>
> The code referenced in your response is just what I used for the
> Windows Common Dialog. =A0What I don't know is how exactly to use or
> incor****ate this into the Shell function. =A0Any specific ideas or
> examples on what this would look like would be helpful and most
> certainly appreciated.
>
> Ruben- Hide quoted text -
>
> - Show quoted text -
Larry,
That's a very interesting observation you made.
Last night I followed your recommendation and created a form using
Access 2003 with only two command buttons on it, pasted your code
behind it and sure enough, it worked just as you said it would. The
files consistently opened in the foreground regardless of the file
type. The only problem I had was getting this to work when pasting the
cmdFollowhyperlink code behind a hyperlink text field. Then files
would consistently open up in the background with the exception of
text files. This may be due to the code I've been using to capture
the file path to the hyperlink text field. For lack of something
better that would work, I placed the following code at the tail end of
the ahtCommonFileOpenSave() function:
Forms!frmDo***ents!txtFileLink =3D ahtCommonFileOpenSave (or
varFileName)
I don't absolutely need to capture this onto a hyperlink text field, I
just wanted the linked file to be visible somehow to the user.
This morning, I tried the same test at work using Access 2000.
Although initially files would open up in the foreground, when I
changed the form to Pop up, files continued to open in the foreground
but Access would now be minimized the moment these files were shut
down.
Would this have anything to do with the fact that Access 2000
currently operates under Windows 2000 while Access 2003 operates under
Windows XP? Whatever the case, I can certainly make it work following
the simple command button model you provided.
Thanks again for the very helpful suggestions you made.
Regards,
Ruben


|