[AccessD] Running local file format

Jim Lawrence (AccessD) accessd at shaw.ca
Mon Nov 3 18:58:19 CST 2003


Hi Andy:

Thanks for the code. Along with the code sample from Dev Ashish's site this
should cover all bases.

Jim

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Andy Lacey
Sent: Monday, November 03, 2003 7:02 AM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] Running local file format


I use some API code that came from someone on the list (sorry can't credit
cos can't remember). Very simple. Stick this in a module:

Declare Function ShellExecute Lib "shell32" 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

Function RunApp(strFile As String, bytSize) As Boolean
Dim lngRet As Long
Dim varTaskID As Variant
Dim strRet As String

lngRet = ShellExecute(hWndAccessApp, vbNullString, strFile, vbNullString,
vbNullString, bytSize)
If lngRet > Success Then
strRet = vbNullString
lngRet = -1
RunApp = True
Else
RunApp = False
Select Case lngRet
Case NotRegistered
varTaskID = Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " & strFile,
bytSize)
lngRet = (varTaskID <> 0)
Case InadequateMemory
MsgBox "Error:  Out of Memory/Resources!"
Case FileNotFound
MsgBox "Error:  File not found!"
Case PathNotFound
MsgBox "Error:  Path not found!"
Case BadFormat
MsgBox "Error:  Bad File Format!"
Case 5
MsgBox "Error:  Unauthorized due to Security restrictions!"
End Select
End If
End Function

Then all you do is:

Call RunApp(strfilename,1)

HTH

--
Andy Lacey
http://www.minstersystems.co.uk




--------- Original Message --------
From: "Access Developers discussion and problem solving"
<accessd at databaseadvisors.com>
To: "accessd at databaseadvisors.com" <accessd at databaseadvisors.com>
Subject: RE: [AccessD] Running local file format
Date: 03/11/03 21:15


Jim,
If you're just wanting to give the ability to open a file from a list, what
I've done in the past is use a continuous form listing the filename and
beside the filename field, add a command button. Set the Hyperlink Address
of the command button to the path and filename via code in the On Current
property of the form. Then the user just clicks on the button and the file
is opened by whatever program the extension is registered as.

HTH

Rusty

-----Original Message-----
From: Jim Lawrence (AccessD) [mailto:accessd at shaw.ca]
Sent: Monday, November 03, 2003 1:47 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] Running local file format


Hi All:

This is a simple question I am sure but the life of me I can not remember or
find the related code. (Advanced years and all)

Can you set up Access to, under program control to run/display any file that
the local computer recognizes, like a Word document, pdf file, spreadsheet
or maybe a web page without writing specific code for each type. I have
written procedures for Word Excel and Web pages but there must be any easier
way than blocks of code for each extension. A browser web page can do this
but can an Access program?

Any suggestions would be greatly appreciated

MTIA
Jim


_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

________________________________________________
Message sent using UebiMiau 2.7.2

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list