Can't reference a .dot via code

G

GrodanBoll

Hi
I'm trying to reference in a .dot template file with code ('code.dot') into another template file ('test01.dot').

I use this code (both files are in the same directory):

test01.dot
Code:
Private Sub Document_New()

Dim msgBoxen As Variant

ThisDocument.VBProject.References.AddFromFile Templates(1).Path & "\code.dot" 'referencing the code file

msgBoxen = MsgBox(Templates(1).Path & "\code.dot is the path", vbCritical) 'Debug code to show the path

Test 'Trying to call a sub from the reference file

End Sub

code.dot
Code:
Public Sub Test()

Dim msgBoxen As Variant

msgBoxen = msgBox("Hello", vbCritical)

End Sub

When I use the test01 template i get this error:
Compile error:
Sub or Function not defined

Do I have to activate the reference code in some way?
When I reference the code via Tools -> Reference it works fine.
I have also tried to use the absolute file path in the reference code, but it still dont work.

What have I done wrong?

Ps
I have tried to repy with this question in a previous thread but it didn't work, so I'm sorry to have to create a new one. :/
Ds
 
W

Word Heretic

G'day "GrodanBoll" <[email protected]>,

You MUST use Application.Run to launch runtime-linked libs. If its set
at compile time, its resolvable. You've been told this already.


Steve Hudson - Word Heretic Sydney Australia
Word eTutor

steve from wordheretic.com (Email replies require payment)


GrodanBoll reckoned:
 
G

GrodanBoll

Hi

I'm sorry Word Heretic.
I have been using http://msdn.microsoft.com/newsgroups/ to post m
questions and the forum was bugging out for me. My post didn't show.

But I see now (through this forum) that I have been doubleposting
lot. Sry for that.

I'll look into the Application.Run.
Thanks for your answers.

Thanks
Groda
 

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