[AccessD] Opening Other Program Files

Heenan, Lambert Lambert.Heenan at AIG.com
Tue Nov 8 10:18:11 CST 2005


I suggest you switch to using the ShellExecute method. It's just much
simpler. Any document type that is registered on the machine will be opened
in it's native application without any need on your part as the programmer
to know where they are installed or what they are called.

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Nicholson, Karen
Sent: Tuesday, November 08, 2005 8:28 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Opening Other Program Files



This is the coding I use:

Option Compare Database   'Use database order for string comparisons
Option Explicit



'Declare Module Level Path Constants
Const WordPerfect = "C:\Program Files\Quick View Plus\PROGRAM\qvp32.exe"
Const MSWord = "C:\cqabapps\viewers\word\wordview.exe"
Const MSExcel = "C:\cqabapps\viewers\excel\xlview.exe"
Const Irfanview = "C:\Program Files\IrfanView\i_view32.exe" Const Autovue =
"C:\Program Files\Volo View Express\Voloview.exe" Const CDView =
"C:\cdview97\cdview.exe" Const PageMaker =
"Q:\install\pm65net\pm65\pm65.exe"
Const CorelDraw = "J:\apps\draw.800\programs\coreldrw.exe"
Const Acrobat = "C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe"
Const MSPowerPoint = "C:\Program Files\Microsoft
Office\Office10\Powerpnt.exe" Const Text = "C:\Program Files\Quick View
Plus\PROGRAM\qvp32.exe"

Function OpenDocument()
On Error Resume Next

Dim strDocType As String, strDocLoc As String
Dim strMsgText As String, strMsgTitle As String
Dim MyAppID As Integer

strDocType = Forms![docDocument]![docDocumentSUB].Form![Extension]
strDocLoc = Forms![docDocument]![docDocumentSUB].Form![Path]

Select Case strDocType
        Case "wpd", "txt"
            MyAppID = Shell(WordPerfect & " " & strDocLoc,
vbMaximizedFocus)
        Case "doc"
            MyAppID = Shell(MSWord & " " & strDocLoc, vbMaximizedFocus)
        Case "xls", "xlw"
            MyAppID = Shell(MSExcel & " " & strDocLoc, vbMaximizedFocus)
        Case "dwg", "dxf", "cal"
            MyAppID = Shell(Autovue & " " & strDocLoc, vbMaximizedFocus)
        Case "tif", "pcx", "bmp", "gif", "jpg"
            MyAppID = Shell(Irfanview & " " & strDocLoc,
vbMaximizedFocus)
        Case "dwgrx"
            MyAppID = Shell(CDView & " " & strDocLoc, vbMaximizedFocus)
        Case "pm5", "pm6", "p65"
            MyAppID = Shell(PageMaker & " " & strDocLoc,
vbMaximizedFocus)
        Case "cdr"
            MyAppID = Shell(CorelDraw & " " & strDocLoc,
vbMaximizedFocus)
        Case "pdf"
            MyAppID = Shell(Acrobat & " " & strDocLoc, vbMaximizedFocus)
        Case "ppt"
            MyAppID = Shell(MSPowerPoint & " " & strDocLoc,
vbMaximizedFocus)
        Case "paper"
            strMsgText = "This document was submitted in paper version
only."
            strMsgTitle = "Document Open Failure"
            MsgBox strMsgText, vbOKOnly + vbExclamation, strMsgTitle
            Exit Function
        Case "prev"
            strMsgText = "This document was previously submitted under
another Task Number." & _
                vbCrLf & "Scroll to the right for more information."
            strMsgTitle = "Document Open Failure"
            MsgBox strMsgText, vbOKOnly + vbExclamation, strMsgTitle
            Exit Function
        Case "mdb"
            strMsgText = "Please press the button 'Open SAF' to view the
application form." & _
                vbCrLf & "The application cannot be opened here."
            strMsgTitle = "Document Open Failure"
            MsgBox strMsgText, vbOKOnly + vbExclamation, strMsgTitle
            Exit Function
        Case Else
            strMsgText = "The document type and path information do no exist
for this entry."
            strMsgTitle = "Document Open Failure"
            MsgBox strMsgText, vbOKOnly + vbExclamation, strMsgTitle
            Exit Function
    End Select
    AppActivate MyAppID

End Function 


Karen S. Nicholson
Programmer Analyst
EG&G Technical Services, Inc.
Pittsburgh, PA
Phone: 412-386-6649
Email: cyx5 at cdc.gov




More information about the AccessD mailing list