Relative File Path for CDROM Distribution

SAK

Registered User.
Local time
Today, 12:07
Joined
Jun 5, 2003
Messages
43
Howdy, I did some searching here and see where Pat Hartman advised someone that Access doesn't support relative file paths for certain purposes. But probably somewhere in VBA coding, there's a solution to what I want to accomplish. Maybe?

Here's my situation. For my coworkers, I am devolping an Access application that will not only do the usual database stuff, but also open other applications (like MS Word and and GIS program) for them. Since all our users are what we call "remote users", i.e. not regularly connected to our network, my strategy was to burn the Access app and associated applications and data on a CD and distribute. My coworkers could then in turn load from the CD to their notebooks and use the files.

So to call the other applications...in the second portion of the Shell Function, wherein the specific application file is designated, is there a way to do the relative path name so the appropriate app will find it wherever the user copies it too?

I tried using \\FolderName\FileName but that I got an error message that file \\FolderName\FileName could not be found.

Ideas anyone?

Thanks
 
G’day SK.

Not really sure what you’re after here but there’s an attached A97 demo anyway.

If it works correctly you should be able to unzip it to any directory and run the Test Sub to get at the Word document.

Hope that is the intention but here is the code as well.


Code:
Option Explicit
Option Compare Text


Public Const conShow         As Long = 1
Public Const conSubDirectory As String = "Applications"


Public Declare Function ShellExecute Lib "shell32.dll" _
                 Alias "ShellExecuteA" (ByVal lngHwnd As Long, _
                                        ByVal strOperation As String, _
                                        ByVal strFile As String, _
                                        ByVal strParameters As String, _
                                        ByVal strDirectory As String, _
                                        ByVal lngShow As Long) As Long


Sub Test()
    Dim strFileName As String
    
    strFileName = "MyWordDocument.doc"
    
    ShellExecute 0, "Open", GetCurrentDB("SubDirectory") & strFileName, "", "", conShow

End Sub


Public Function GetCurrentDB(ByVal strArgument As String) As String

    Select Case strArgument
           
        Case "User"
            GetCurrentDB = CurrentUser()
        
        Case "PathAndName"
            GetCurrentDB = CurrentDb.Name
        
        Case "FullName"
            GetCurrentDB = Dir(CurrentDb.Name)
        
        Case "Extension"
            GetCurrentDB = Right$(Dir(CurrentDb.Name), 4)
        
        Case "Name"
            GetCurrentDB = Left$(Dir(CurrentDb.Name), Len(Dir(CurrentDb.Name)) - 4)
        
        Case "Path"
            GetCurrentDB = Left$(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name)))
        
        Case "SubDirectory"
            GetCurrentDB = Left$(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name))) & conSubDirectory & "\"
        
        Case Else
            GetCurrentDB = "GetCurrentDB(" & Chr$(34) & strArgument & Chr$(34) & ") :- Invalid argument."

    End Select
    
End Function

Regards,
Chris.
 

Attachments

Users who are viewing this thread

Back
Top Bottom