Relative path

  • Thread starter Thread starter saymard
  • Start date Start date
S

saymard

Hi, here is my beginner problem

I wrote this code to access to a Word document from an Access
application. It works but I would like avoid the complete path for this
code to work on every machine.

the complete path is in my variables : accessDossier & operation

could someone tell me how to access directly to the document that is in
the file "Documents" at the same level as my Access application is ?

I need a relative path, I tried ..\Documents\Operation_1 but it didn't
work.

Here is the function to access to the word document :

Public Function hypertext(document As String)
Dim numErreur As Integer

Dim Word As Object
Dim accesDossier As String
Dim accesComplet As String
Dim operation As String

accesDossier = "C:\WINDOWS\Profiles\E SAYMARD\Bureau\Base
VUD\Documents\Operation_"
operation = forms("F_Op").Controls("Id_Ope")

accesComplet = accesDossier & operation '& "/"

Set Word = CreateObject("Word.Application")
Word.ChangeFileOpenDirectory accesComplet
Word.Documents.Open FileName:=document
Word.Visible = True

End Function


Thanks for your help

Eric
--
 
saymard said:
I wrote this code to access to a Word document from an Access
application. It works but I would like avoid the complete path for this
code to work on every machine.

the complete path is in my variables : accessDossier & operation

could someone tell me how to access directly to the document that is in
the file "Documents" at the same level as my Access application is ?

I need a relative path, I tried ..\Documents\Operation_1 but it didn't
work.

Here is the function to access to the word document :

Public Function hypertext(document As String)
Dim numErreur As Integer

Dim Word As Object
Dim accesDossier As String
Dim accesComplet As String
Dim operation As String

accesDossier = "C:\WINDOWS\Profiles\E SAYMARD\Bureau\Base
VUD\Documents\Operation_"
operation = forms("F_Op").Controls("Id_Ope")

accesComplet = accesDossier & operation '& "/"

Set Word = CreateObject("Word.Application")
Word.ChangeFileOpenDirectory accesComplet
Word.Documents.Open FileName:=document
Word.Visible = True

You can retrieve the full path to your application with
CurrentDb.Name

In A2K+, the full path to your application:
CurrentProject.FullName
and just the path:
CurrentProject.Path
 
You can retrieve the full path to your application with
CurrentDb.Name

In A2K+, the full path to your application:
CurrentProject.FullName
and just the path:
CurrentProject.Path

Thank you, it works.

I have another question
I try to change the link of linked tables to be sure to have a the good
connection if I change the location of my Database.

Here is the code that doesn't work

dim newLink as string
dim path as string

path = currentProject.Path

newLink = ";DATABASE=" & path & "\new_source.mdb"

currentDb.TableDefs(i).Connect = newLink
currentDb.TableDefs(i).RefreshLink

Thanks for your help
 
Back
Top