473,507 Members | 8,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Files launched w/ Followhyperlink open but not visible

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
Jun 27 '08 #1
5 5110
On 8 May, 01:23, Ruben <rubenfmu...@gmail.comwrote:
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

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
Jun 27 '08 #2

"Ruben" <ru*********@gmail.comwrote in message
news:87**********************************@y21g2000 hsf.googlegroups.com...
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:da****@hotmail.com",WIN_NORMA L)
'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 **********
Jun 27 '08 #3
On May 8, 1:21*pm, "paii, Ron" <n...@no.comwrote:
"Ruben" <rubenfmu...@gmail.comwrote in message

news:87**********************************@y21g2000 hsf.googlegroups.com...
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...@hotmail.com",WIN_NORM AL)
'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'tExecute!"
* * * * * * 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
Jun 27 '08 #4

"Ruben" <ru*********@gmail.comwrote in message
news:50**********************************@34g2000h sf.googlegroups.com...
On May 8, 1:21 pm, "paii, Ron" <n...@no.comwrote:
"Ruben" <rubenfmu...@gmail.comwrote in message

news:87**********************************@y21g2000 hsf.googlegroups.com...
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...@hotmail.com",WIN_NORMA L)
'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.
Jun 27 '08 #5
On May 9, 5:13*am, "paii, Ron" <n...@no.comwrote:
"Ruben" <rubenfmu...@gmail.comwrote in message

news:50**********************************@34g2000h sf.googlegroups.com...
On May 8, 1:21 pm, "paii, Ron" <n...@no.comwrote:


"Ruben" <rubenfmu...@gmail.comwrote in message
news:87**********************************@y21g2000 hsf.googlegroups.com...
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...@hotmail.com",WIN_NORMA L)
'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
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5373
by: Moosebumps | last post by:
So say I am working on two separate .py files in IDLE that are part of the same program. Does anyone have problems where when you modify one file, and then run the other, the changes you made in...
1
7214
by: Lauren Quantrell | last post by:
I'm using the following code in Access 2000 to open a new MS Internet Explorer window with whatever URL value I pass to myURL: Application.FollowHyperlink myURL, , True (the True opens MS Internet...
2
1309
by: Andy Kim via AccessMonster.com | last post by:
Can anyone help with providing an option to attach files such as MS Word or Excel document to a database record and be able to view without having to store the document as an OLE object? I want to...
0
1849
by: lknight643 | last post by:
I have an asp.net application that works with a SQL server database on server No. 1 but I want to upload files for storage to Server No. 2 that is accessible only from the Internet. If the file...
2
4571
by: AlastairHardwick | last post by:
Hi, Wonder if you can help? I have an Image Management Database which holds various information relating to Ghost Images and Testing. I am using a textbox with a hyperlink to display the path...
3
3667
by: df | last post by:
In the old days of Visual Basic for Applications, I successfully opened a file (of any file type: .dwg .pdf .doc etc) in its own application using: ActiveWorkbook.FollowHyperlink...
5
1963
by: JimmyKoolPantz | last post by:
Situation: I am writing a program that opens up a data file (file ext .dbf), imports the information into a dataset. The program also, searches through the dataset for key words ("company...
5
1489
by: jpr | last post by:
Hello, I would like to create a sort of lookup form with two listboxes. The firts should read all the drives on my workstation. According to the drive selected, the second listbox should display...
7
7705
by: fpesante | last post by:
Hi, I I'm trying to create a form on database that user can choose and adress from a list box then click on a command button and they will be able to open the site. I am not able to retreive the...
0
7313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7481
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5039
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3190
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1537
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.