Passing values from one .dot files to another .dot files

S

Srini

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("Firs­tName").Range.Text =
Me.txtFirstName.Text
ActiveDocument.Bookmarks("EmpN­umb").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("bksa­lary").Range.Text = salary
test2.Show
End Sub

Public Function salary() As String
Dim sal As String
If
(ActiveDocument.CustomDocument­Properties.Item("Employee").Va­lue
= "1") Then
salary = "100K"
ElseIf
(ActiveDocument.CustomDocument­Properties.Item("Employee").Va­lue = "
")
Then
salary = "Salary not generated"
End If
End Function

Private Sub CmdFinish2_Click()
ActiveDocument.Bookmarks("Last­Name").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
 

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