relative vs. absolute path problem

  • Thread starter Thread starter Gina
  • Start date Start date
G

Gina

Hi all.

I am having a problem telling access to take the dokument template which is
in the same directory as the mdb file
this version works:

Set WD = CreateObject("Word.Document", "Dell")
Set DC = Word.Documents.Add("C:\Test\Rechnung1.dot", , , True)

whereas here I get a message '5151' saying that the doc isn't not there :

Set DC = Word.Documents.Add("Rechnung1.dot", , , True)

how can I write the path in a relative way without having to define the
absolute path of the actual template ??

Thanks
Gina
 
Hi Nick.

tried that already ...

tried numerous variations like

...\Rechnung1.dot
..\Rechnung1.dot
../Rechnung1.dot (which wouldn't have made real sense here - anyway)

I even created a folder named 'Template' and put the template into a folder
trying to call it:

..\Template\Rechnung1.dot

but failed and can't understand why !!!!

Gina
 
In Gina typed:
Hi all.

I am having a problem telling access to take the dokument
template
which is in the same directory as the mdb file
this version works:

Set WD = CreateObject("Word.Document", "Dell")
Set DC = Word.Documents.Add("C:\Test\Rechnung1.dot", ,
, True)

whereas here I get a message '5151' saying that the doc
isn't not
there :

Set DC = Word.Documents.Add("Rechnung1.dot", , , True)

how can I write the path in a relative way without having
to define
the absolute path of the actual template ??

Thanks
Gina

Try .\Rechnung1.dot IIRC that might work.

That is dot backslash. Old DOS trick - dot is the current
dir and dot dot is parent dir.
 
In Gina typed:
Hi Nick.

tried that already ...

tried numerous variations like

..\Rechnung1.dot
.\Rechnung1.dot
./Rechnung1.dot (which wouldn't have made real sense
here - anyway)

I even created a folder named 'Template' and put the
template into a
folder trying to call it:

.\Template\Rechnung1.dot

but failed and can't understand why !!!!

Gina

There's a global property in Access which contains the
current path...
CodeProject.Path see also CurrentProject

So WD = CodeProject.Path & 'rechtnung1.doc'

Can't remember if Path returns a trailing \ you may need to
add one.
 
CurrentDB.Path should also work.

Nick Coe (UK) said:
In Gina typed:

There's a global property in Access which contains the
current path...
CodeProject.Path see also CurrentProject

So WD = CodeProject.Path & 'rechtnung1.doc'

Can't remember if Path returns a trailing \ you may need to
add one.
 
Thanks Nick,

thanks to all the others as well

reVorlage = CurrentProject.Path & "\Rechnung1.dot"

for the most helpful hint

Gina :)
 
Back
Top