ActiveDocument.Add with passing parameter issue

N

Nick

Hi All,

I have two word templates (A1, A2) and what i am trying to do using VB code
is that create a new document base on A2 template when A1 is creating.

So i write ActiveDocument.Add(Path of A2) code inside the new() in A1. Now i
have issue that how to pass a parameter to A2 when creating document , so
that A2 code behind knows that this is creating from A1 . as the behavior are
different if A2 create by itself.

I tried using ActiveDocument.Add(path of A2, ,, false) code in A1, and using
if (not activedocument.windows(1).visiable ) then it's calling from A1 , but
it does't seem work as activedocument.windows(1).visiable is always return
true.

am i on right track to achieve this or is that any other ways can do?

any helps are appreciated..

Thanks

nick
 
R

Rob

You can't pass anything in Add(). I think I'd want to know why A2 needs to
know A1 created it to give any kind of useful answer, but you might try
setting a A1 as a reference in A2 and using a global variable.
 
N

Nick

hi Rob,

When i create a new document base on A2 template , it will pop up a macro
form to allwo user to enter information. (form load in new() function in A2).

But i don't wanna the macro form pop up when a new document been created
base on A2 template from A1 creating.

That's why i need detect sth to distingish this two cases ?

Thanks

Nick
 
R

Rob

Let me see if I understand what you're saying. You have two templates, A1 and
A2. A2 can sometimes be used without A1, so the Document_New thing is needed.
But when A2 is created by a macro in A1, it isn't needed. Is that right?

It seems like the easiest solution would be to just create another similar
document, A3, without any auto macro in it to be used with A1.
 
N

Nick

Yeah. you are correct.

But we only want to keep on entry of A2 template.

I actually find a solution to achieve.

Firstly , in macro of A1, i write Documents.add("path of A2", false,
newblankdocument, false) to create a new document with window visible is
false.
so what you got is a new document with no content.

then, in the new() function of A2, if activedocument.windows.count = 0
,which means it's calling from A1 , then
activedocument.windows.add(newwindow), to create a new windows. so name of
document would be sth like "Document2:1" and "Document2:2"
that is because Document 2 has two windows. then i close the visible is
false window.

finally , from the user point view , they only can see a new document have
been create base on A2 template.

It is bit hard to explain , hopefully you know what i am saying here.

Thanks for you replies , anyway.

Cheers

Nick
 

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