Word 2002 VBA question: calling subroutines from an "add-in" template

J

Jonathan West

Hi Avraham,

A couple of questions.

1. Is the sub you are calling declared as Public?

2. Is the template containing the sub currently open at the time you make
the call. By "open" i mean one of the following

- the template is loaded as an add-in
- the template is open in an editing window
- a document based on the template is open in an editing window

Unless the template is open and the Sub declared as public, Application.Run
will not work.

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
H

Helmut Weber

Hi Avraham,

there is nothing wrong with you code,
except that it doesn't work,
which is a known bug. ;-)

Use something like this instead,
as Manfred Fasler in the German gruops told me:

Application.Run "SystemwideUniqueModulename.SubName" or
Application.Run "SystemwideUniqueSubName".

There ought to be an article in the knowledgebase,
but I can't find it.

Greetings from Bavaria, Germany

Helmut Weber, MVP, WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
A

Avraham Makeler

BS"D

Hi all,

This is a Word 2002 VBA question. (Maybe I am on the wrong forum, but the
VBA forums I have access to right now all seem to be pretty quite.)

I am running from within the "main" document template, and I am trying to
call a subroutine declared within a second (add-in?) template. (I added this
second template entering the [Tools|Templates and Add-ins] dialog box and
using the [Global Templates and add-ins].Add function).

I have got as far as successfully opening the second template, called
EditioningTemp.dot, as follows:
Documents.Open (ActiveDocument.Path & "\EditioningTemp.dot")

Now I am supposed to call the subroutine (with its parameters) and I can't
seem to get the path right.

I have tried all the following forms, but the VB interpreter always yells at
me "object required"!:

1. Call EditioningTemp.Module1.Subr1

2. Application.Run MacroName:="EditioningTemp.Module1.Subr1"

3. Application.Run MacroName:=strTemplate & "." & strModule & "." &
strMacro, varg1:=strParameter

It seems to be that the interpreter can't 'see' inside the specified module.

If I can't do this, this would be a shame, since I will have to copy all the
content from the add-in into the main template.

Any ideas? Or maybe I am on the wrong forum? The VBA forums seem to be
pretty quite.

tia

Avraham.
 

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