Iam New member for this group!!!!
My project is to pass values from .dot file to another .dot file (lets
say two .dot files test1.dot and test2.dot)
test1.dot: When user runs the macro go(), the wizard / form will be
open to enter the employee number, once he enters, it prints the
Employee number in a document (Doc1) and saved it to the disk, after
this it will open test2.dot
test2.dot: This should calculate the salary based on the employee
number received from the test1.dot, and attach the salary component to
the earlier created file (Doc1) by test1.dot
Iam not sure how to pass the values from one .dot file to another .dot
file
test1.dot code
=============Private Sub CmdFinish1_Click()
ActiveDocument.Bookmarks("FirstName").Range.Text Me.txtFirstName.Text
ActiveDocument.Bookmarks("EmpNumb").Range.Text = Me.TextBox1
test1.Enabled = False
ActiveDocument.SaveAs FileName:="C:\doc1.dot"
ActiveDocument.SaveAs FileName:="C:\doc2.dot"
Call test2
Unload Me
Application.Quit
End Sub
Public Function test2()
Dim wrdAppl As Word.Application
Set wrdAppl = New Word.Application
wrdAppl.Documents.Open ("C:\test2.dot")
Set wrdAppl = Nothing
End Function
test2.dot code
=============Private Sub Document_Open()
ActiveDocument.Bookmarks("bksalary").Range.Text = salary
test2.Show
End Sub
Public Function salary() As String
Dim sal As String
If
(ActiveDocument.CustomDocumentProperties.Item("Employee").Value
= "1") Then
salary = "100K"
ElseIf
(ActiveDocument.CustomDocumentProperties.Item("Employee").Value
= "
") Then
salary = "Salary not generated"
End If
End Function
Private Sub CmdFinish2_Click()
ActiveDocument.Bookmarks("LastName").Range.Text Me.txtLastName.Text
Dim Doc1 As Word.Document
Set Doc1 = GetObject("C:\doc1.dot", "Word.Document")
Doc1.Range = Doc1.Range + ActiveDocument.Range
Doc1.SaveAs FileName:="C:\doc3.dot"
Doc1.Close 'close doc3
Set Doc1 = Nothing
Unload Me
ActiveDocument.Close 'close test2.dot
End Sub
in test2.dot
===========I have written code to read the values from customdocumentproperties if
we want to see manually ..open any document go to File menu ->
Properties -> Custom Tab.
What i need is to get the employee number from test1.dot to the custom
properties of the test2.dot so that i can perform necessary salary
calculations
If any of know how to pass the values from .dot file to another .dot
file will be a great help
You can directly mail to me if you need the test1.dot and test2.dot
files for any clarification
I will also update the groups as and when required
Thanks
Srini
Doug Robbins - 18 Aug 2005 21:12 GMT
Why use two templates? It could all be done with one.

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
Iam New member for this group!!!!
My project is to pass values from .dot file to another .dot file (lets
say two .dot files test1.dot and test2.dot)
test1.dot: When user runs the macro go(), the wizard / form will be
open to enter the employee number, once he enters, it prints the
Employee number in a document (Doc1) and saved it to the disk, after
this it will open test2.dot
test2.dot: This should calculate the salary based on the employee
number received from the test1.dot, and attach the salary component to
the earlier created file (Doc1) by test1.dot
Iam not sure how to pass the values from one .dot file to another .dot
file
test1.dot code
==============
Private Sub CmdFinish1_Click()
ActiveDocument.Bookmarks("FirstName").Range.Text =
Me.txtFirstName.Text
ActiveDocument.Bookmarks("EmpNumb").Range.Text = Me.TextBox1
test1.Enabled = False
ActiveDocument.SaveAs FileName:="C:\doc1.dot"
ActiveDocument.SaveAs FileName:="C:\doc2.dot"
Call test2
Unload Me
Application.Quit
End Sub
Public Function test2()
Dim wrdAppl As Word.Application
Set wrdAppl = New Word.Application
wrdAppl.Documents.Open ("C:\test2.dot")
Set wrdAppl = Nothing
End Function
test2.dot code
==============
Private Sub Document_Open()
ActiveDocument.Bookmarks("bksalary").Range.Text = salary
test2.Show
End Sub
Public Function salary() As String
Dim sal As String
If
(ActiveDocument.CustomDocumentProperties.Item("Employee").Value
= "1") Then
salary = "100K"
ElseIf
(ActiveDocument.CustomDocumentProperties.Item("Employee").Value
= "
") Then
salary = "Salary not generated"
End If
End Function
Private Sub CmdFinish2_Click()
ActiveDocument.Bookmarks("LastName").Range.Text =
Me.txtLastName.Text
Dim Doc1 As Word.Document
Set Doc1 = GetObject("C:\doc1.dot", "Word.Document")
Doc1.Range = Doc1.Range + ActiveDocument.Range
Doc1.SaveAs FileName:="C:\doc3.dot"
Doc1.Close 'close doc3
Set Doc1 = Nothing
Unload Me
ActiveDocument.Close 'close test2.dot
End Sub
in test2.dot
============
I have written code to read the values from customdocumentproperties if
we want to see manually ..open any document go to File menu ->
Properties -> Custom Tab.
What i need is to get the employee number from test1.dot to the custom
properties of the test2.dot so that i can perform necessary salary
calculations
If any of know how to pass the values from .dot file to another .dot
file will be a great help
You can directly mail to me if you need the test1.dot and test2.dot
files for any clarification
I will also update the groups as and when required
Thanks
Srini
Srini - 18 Aug 2005 21:51 GMT
Doug,
I need to do exactly as what i have said. This is the requirement
what i told here is only the prototype of the original problem. I can
do necessary changes to the original code if this problem is fixed
In real time, these two are different projects whch are running
independently. Now i need the content of both test1 and test2 in one
shot without disturbing the existing functionality
#1 test1.dot
#2 test2.dot
where
#1 can be executed independently without calling #2
#1 can be executed by calling #2
#2 can be executed independently or can be called by someother project
(say #1)
so to start test2.dot (if control is coming from #1), i need to know
the values which are passed to test2.dot
This is how i ended in typing this big mail.
Pls help
Thanks
Srini
Jean-Guy Marcil - 19 Aug 2005 02:04 GMT
Srini was telling us:
Srini nous racontait que :
> Doug,
>
> I need to do exactly as what i have said. This is the requirement
> what i told here is only the prototype of the original problem. I can
> do necessary changes to the original code if this problem is fixed
What Doug meant, I think, is that all you need is a global template in the
start-up folder that would hold all the code. This template would create
your test1.doc and test2.doc from two other templates that would not need to
have any code in them. This way, it is easy to pass variables around within
the same project, even within the same module.

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Doug Robbins - 19 Aug 2005 05:01 GMT
Not what I was thinking of, but there is more than one way to skin a cat.

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Srini was telling us:
> Srini nous racontait que :
[quoted text clipped - 10 lines]
> to have any code in them. This way, it is easy to pass variables around
> within the same project, even within the same module.
Cindy M -WordMVP- - 20 Aug 2005 10:26 GMT
Hi Srini,
Well, the first problem I see, when doing a quick scan of your code, is
that you're actually OPENING test2.dot. One normally wouldn't do this
with a template. Is there a reason you're OPENING the template, rather
than creating a new document from it?
Generally, if you're opening a file (be it .doc or .dot), you assign it
to an object variable. Example:
Dim docTest2 as Word.Document
Set docTest2 = Documents.Open(test2.dot)
Now, you can work with it's document properties or document variables
docTest2.CustomDocumentProperties("Salary").Value = number
Your biggest problem is that you have to learn to use object variables,
instead of "ActiveDocument". Once you do that, things will become MUCH
easier :-)
> My project is to pass values from .dot file to another .dot file (lets
> say two .dot files test1.dot and test2.dot)
[quoted text clipped - 81 lines]
> files for any clarification
> I will also update the groups as and when required
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
Srini - 23 Aug 2005 00:11 GMT
Cindy,
Thanks for ur reply. I tried the way you have said but iam getting a
problem "Invlid procedure call or argument"
What i see here is
test2 -> has the funcitonality of retriveing some values from database
based on the Employee number (This value is from custom document
properties) before it opens so in our case we are assigning the value
after it opens where it throws an error.
i need to figure it out to pass that value before the document is
opened
Dim docTest2 as Word.Document
Set docTest2 = Documents.Open(test2.dot)
docTest2.CustomDocumentProperties("Salary").Value = number
I fyou have any ideas pls share
Thanks
Cindy M -WordMVP- - 23 Aug 2005 14:57 GMT
Hi Srini,
> Thanks for ur reply. I tried the way you have said but iam getting a
> problem "Invlid procedure call or argument"
[quoted text clipped - 12 lines]
>
> I fyou have any ideas pls share
Note: if this is exactly the code you're using, then it's incorrect.
There is no hyphen in "CustomDocumentProperties".
Other than that, I'm afraid I don't understand what you mean. The code
example you show me is opening the document before trying to set the
value. You can't insert something into a document before the document is
opened. You can save it in a variable, in memory, until the document is
opened. You can save it in an INI or other text file, and retrieve it
later.
Does the property even exist in the document, or do you need to create
it first?
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :-)
Srini - 30 Aug 2005 23:00 GMT
Cindy,
The current project was postponed. I will take your help once iam back
to that project.
Thanks for assistence
Thanks
Srini