relative vs. absolute path problem

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
 
G

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
 
N

Nick Coe \(UK\)

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.
 
N

Nick Coe \(UK\)

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.
 
G

Guest

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.
 
G

Gina

Thanks Nick,

thanks to all the others as well

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

for the most helpful hint

Gina :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top