open .doc file

benjamin.grimm

Registered User.
Local time
Yesterday, 19:11
Joined
Sep 3, 2013
Messages
125
hello

i want to open different .doc files by a button from access.

I want that the vba code checks where the current access database is located. In which folder the the current access database is.

In this file folder i have a folder called documents.

In this folder i have the .doc files.

Right now i have the following code.

Code:
[FONT=Courier New]Public Function getPath(ByVal iPath As String)
    Dim fso As Object
    Dim drive As String
    Set fso = CreateObject("Scripting.FileSystemObject")
    drive = fso.GetDriveName(CurrentDb.Name)
    getPath = fso.BuildPath(drive, iPath)
    Set fso = Nothing
End Function

Dim sPath As String
    MsgBox "Das Arbeitsblatt 6 wird geöffnet "
    sPath = getPath("\BUS MMM C\Grimm\Masterarbeit\Datenbank\documents\Wissen.doc")
    Application.FollowHyperlink sPath
Exit Sub
Fehlerbehandlung:
MsgBox Err.Description, vbCritical, "Das Arbeitsblatt 6 ist nicht abgelegt!!!"[/FONT]

The access database is in the folder Z:\BUS MMM C\Grimm\Masterarbeit\Datenbank\

I would like to have something like

spath = getpath("documents\wissen.doc")

How can i do that?

Thanks in advance

greetz benjamin
 
the access database is located in

currentproject.path

so maybe this - it can all be parameterised as you require

spath = currentproject.path & "\" & "documents\wissen.doc"
 
It works.

Great thank you.
 

Users who are viewing this thread

Back
Top Bottom